Good Afternoon,
I am trying to run this script remotely and I keep receiving the following error:
Register-ScheduledTask : No mapping between account names and security IDs was
done.
(42,4):UserId:
At C:\TempSQL\FullSQLBackupInstaller.ps1:39 char:13
+ Register-ScheduledTask -TaskName 'crebackup' -InputObject ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (PS_ScheduledTask:Root/Microsoft/.
..S_ScheduledTask) [Register-ScheduledTask], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070534,Register-ScheduledTask
Here is the script:
function windowsTask {
$taskName = "crebackup"
$taskExists = Get-ScheduledTask | Where-Object {$_.TaskName -like $taskName}
if($taskExists) {
Start-ScheduledTask -TaskName "crebackup"}
else {
$Action= New-ScheduledTaskAction -Execute "C:\POSNation\SQLBackup\SQLBackup.exe" -WorkingDirectory "C:\POSNation\SQLBackup\"
$Trigger = New-ScheduledTaskTrigger -Daily -At 3am
$Settings = New-ScheduledTaskSettingsSet
$Task = New-ScheduledTask -Action $Action -Trigger $Trigger -Settings $Settings
Register-ScheduledTask -TaskName 'crebackup' -InputObject $Task -User $env:UserName
}
#$taskName = "crebackup"
$taskExists = Get-ScheduledTask | Where-Object {$_.TaskName -like $taskName
}
User contributions licensed under CC BY-SA 3.0