Database Reference
In-Depth Information
5.
Add the following to
HighCommission.ps1
to set up the
Invoke-Script
call:
try {
$script:_scriptDir = (Get-ScriptDirectory)
. (join-path $_scriptDir Utilities.ps1)
if (Get-CanTranscribe) {
try { Stop-Transcript | out-null } catch { }
Start-Transcript -path (join-path $_scriptDir
"HighCommissionLog.txt")
}
Invoke-Script
}
catch [System.Exception] {
$error = ("Script failed with error: {0}{1}{1}Script: {2}
Line,Col: {3},{4}" `
-f $_.Exception.ToString(), [Environment]::NewLine,
$_.InvocationInfo.ScriptName, `
$_.InvocationInfo.ScriptLineNumber, $_.InvocationInfo.
OffsetInLine)
Write-Error $error; Exit 100
}
finally {
if (Get-CanTranscribe) { Stop-Transcript }
}
6.
Open the Task Scheduler via
Win + R
, type
Taskschd.msc
, then press
Enter
.
7.
Click Create Basic Taskā¦ from the Actions panel. Supply a task name and click
Next until you get to the Start a Program step.
8.
For the Program/script ield, enter the appropriate path to PowerShell:
%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe
9.
For Add arguments, use the following, changing the paths as needed:
-NonInteractive -Command "& c:\Scripts\HighCommission.ps1
-outputPath 'C:\Dropbox\Report Outbox\' -commissionThreshold
.3; exit $LASTEXITCODE"
10. Run the scheduled task, and then inspect the output iles
HighCommissionLog.
txt
and
HighCommission.csv
.
Search WWH ::
Custom Search