[PS] Enabling and disabling a single user account in Windows 7
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:
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
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
Answers (0)
Please log in to answer
Be the first to answer this question

so that the conversation will remain readable.