This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Send-Email($to, $cc, $subject, $body) | |
{ | |
$From = "you@domain.com" | |
$SmtpHost = "smtp.domain.com" | |
Send-MailMessage -From $From -Subject $subject -To $to -Cc $cc -Body $body -BodyAsHtml -SmtpServer $SmtpHost | |
} | |
$To = "user1@domain.com", "user2@domain.com" | |
$Cc="boss@domain.com" | |
$Subject = "Don't worry, it is a test." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference="Stop" | |
$DebugPreference="Continue" | |
trap | |
{ | |
Write-Debug "=== Enter trap ===" | |
$funcName = (Get-PSCallStack)[1].Position.Text | |
$detail = $_ | Out-String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Initialization | |
$script_info = Get-Item $MyInvocation.MyCommand.Definition | |
$script_dir =$script_info.Directory | |
. "$script_dir\GlobalFunctions.ps1" | |
$DebugPreference = "Continue" | |
$ErrorActionPreference = "Stop" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Execute-command($commandPath) | |
{ | |
Set-Location $env:TEMP | |
Log-Info "Command: $commandPath" $logFile | |
cmd /c "$commandPath" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## To read the config file with same name as script file in same folder | |
function Read-ConfigFile($scriptItem) | |
{ | |
$configFile = $scriptItem.BaseName + ".xml" | |
$configFilePath = Join-Path $scriptItem.Directory $configFile | |
Log-Info "Config: $configFilePath" | |
Get-Content $configFilePath | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-LogDir($env) | |
{ | |
$dir = $globalConf.LogDir | |
New-Item -Path $dir -ItemType "Directory" -Force | Out-Null | |
return $dir | |
} | |
function Init-LogFile($env, $stepName) | |
{ | |
$logDir = Get-LogDir $env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Start-TheService([string]$svc) | |
{ | |
$STOP = "Stopped" | |
$RUN = "Running" | |
"Starting $svc..." | |
$s = get-service -name $svc | |
"Original status is : " + $s.Status | |
if($s.Status -eq $STOP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Restore nuget packages | |
set nuget="%~dp0\Tools\nuget.exe" | |
pushd "%~dp0" | |
%nuget% restore MyApp.sln | |
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Block-Processes ($pattern) | |
{ | |
# $pattern=@("Spirit.*") | |
$proc = Get-Process -Name $pattern | |
foreach($p in $proc) | |
{ | |
if($p -ne $null) | |
{ | |
Stop-Process $p.Id -Force | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Add TimeStamp | |
$thedate = Get-Date -format "yyyy-MM-dd" | |
$logfile = "OpenWebPage" + "$thedate" + ".txt" | |
$thefiledate = Get-Date -format "yyyy-MM-dd HH:mm:ss" | |
Add-Content $logfile "`nTime Started(yyyyMMddHHmm) $thefiledate " | |
$urlsplit = "http://weburl:8629/path".Split(':') | |
$portsplit = ":8629/path" | |
$urlport = $urlsplit[0] + ":" + $urlsplit[1] + $portsplit | |
$fport = $urlport + "query?value=test" |
OlderNewer