4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SC(非公式)Advent Calendar 2018

Day 18

PowershellDSCでスケジューラータスクを更新する際の注意点

Last updated at Posted at 2019-01-15

powershellDSCでスケジューラータスクを登録しようとしたときに

No mapping between account names and security IDs was done.
(43,4):UserId:
    + CategoryInfo          : NotSpecified: (PS_ScheduledTask:) [], CimException
    + FullyQualifiedErrorId : HRESULT 0x80070534,Register-ScheduledTask

こんなエラーが発生しました。

なので一部抜粋したコードですが、下記のように、ユーザーIDを指定してあげると無事に登録できました。


$Action = New-ScheduledTaskAction -Execute $Execute -Argument $JoindArgs
$Trigger = New-ScheduledTaskTrigger -AtStartup 
$Settings = New-ScheduledTaskSettingsSet -DontStopIfGoingOnBatteries -RestartCount 999 -StartWhenAvailable 
$Settings.RestartInterval="PT1M"
$Settings.ExecutionTimeLimit="PT0S"
    
$userinfo = [System.Security.Principal.WindowsIdentity]::GetCurrent()
Register-ScheduledTask -TaskPath \ -TaskName $TaskName -Action $Action -Trigger $Trigger -Settings $Settings -User $userinfo.Name -Force

通常のPSでもPSRemotingでもエラーが出なかったもので

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?