34 lines
1.2 KiB
PowerShell
34 lines
1.2 KiB
PowerShell
<# Scheduled Task metadata
|
|
General
|
|
SetVMTagNadMovToAppNameFolder
|
|
run as ndgov\svcitdiaassched
|
|
run whether user is logged on or not
|
|
run with highest privileges
|
|
Triggers
|
|
Daily, 10:15am, repeat every 8 hours
|
|
Actions
|
|
"C:\Program Files\PowerShell\7\pwsh.exe" -file "D:\PowerShellTasks\SyncVMwareDatastoresToSharePoint\SyncVMwareDatastoresToSharePoint.ps1"
|
|
|
|
Settings
|
|
allow task to be run on demand
|
|
stop the task if it runs longer than 3 days
|
|
if the running task does not end when requested, force it to stop
|
|
#>
|
|
|
|
$TimeStamp = Get-Date -UFormat "%Y%m%d-%H%M%S"
|
|
$TranscriptPath = "F:\SyncVMwareDatastoresToSharePoint\Logs\SyncVMwareDatastoresToSharePoint-$Timestamp.log"
|
|
Start-Transcript $TranscriptPath
|
|
|
|
try
|
|
{
|
|
Connect-ITDvCenter -Credential $svcitdvmvcauto
|
|
Sync-ITDVMwareSharePointDatastoreRecord -SharePointCredential $svcitdiaassprw -verbose
|
|
Disconnect-VIServer -Server * -Confirm:$flse
|
|
}
|
|
catch
|
|
{
|
|
Send-MailMessage -To itdvctremailalerts@nd.gov -From itdvmvcp1script@nd.gov -Subject "Task SyncVMwareDatastoresToSharePoint errored" -Body "Task started $TimeStamp.`nCheck logs for further information" -SmtpServer apprelay1.nd.gov
|
|
}
|
|
|
|
|
|
Stop-Transcript |