First off lets get all the set up variables out of the way. A lot of these are the same variables I use in every script and I just copy them in each time so you may not want to use them all.
|
[cc lang="powershell"]$Transpath = $env:LOCALAPPDATA + "\Cloudwyse\Logs\scheduled_task_Report_" + $(get-date –Format ddMMyy_HHmmss) + ".log" Start-Transcript –Path $TransPath –NoClobber $DateTime = (Get-Date).ToString('ddMMyy_HHmmss') $ResultsPath = "C:\Cloudwyse\Scripts\Output\Scheduled_Task_Test_Output_" + $DateTime + ".csv" $Date = Get-Date –Format "dd-MM-yyyy" $Pass = cat C:\mysecurestring.txt | convertto-securestring $Cred = new-object –typename System.Management.Automation.PSCredential –argumentlist "CONTOSO\rick.sanchez",$Pass $DC = "DC01.contoso.com" $TaskReport = @() $TestedServers = 0 $OutputPath = "C:\Cloudwyse\Scripts\Output" $SplitSeparator = "" $SplitOption = [System.StringSplitOptions]::RemoveEmptyEntries[/cc] |
I like to use Write-Output to add the actions to the…