I wrote a Test.ps1 script that is started during startup of Windows 7. To do this, I created a scheduled task in this way:

schtasks /create /sc onstart /ru System /v1 /z /tn "Test" /tr "C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -file \"D:\Users\xxx\Documents\Test.ps1\" \"Administrator test\""

Since this script is 45 minutes and, in that time, the "Administrator test" administrator not must log on, I wrote at the beginning and end of this script, follow these instructions:


param($AdministratorAccount)

Get-WmiObject Win32_UserAccount -filter "LocalAccount=True AND Name=$AdministratorAccount" | % {$_.disable = $true;$_.put()}

.............
.............
.............

Get-WmiObject Win32_UserAccount -filter "LocalAccount=True AND Name=$AdministratorAccount" | % {$_.enable = $true;$_.put()}


I noticed, however, that during the execution of that script, the "Administrator test" administrator can still access the system with the "Administrator test" account.

Where I wrong?

THANKS

BYE
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

There are no answers at this time
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

Answer this question or Comment on this question for clarity