![](/img/trans.png)
[英]How do I create a scheduled task on the command line that runs as local administrator to run a task that runs as a different user?
[英]How can I turn a local user into an administrator via the PowerShell command line?
在这里是PowerShell新手,我正在编写一个脚本,该脚本准备将新安装的PC与我的IT公司网络合并。 我在将通过PowerShell创建的本地用户帐户转换为本地管理员时遇到了一个任务。
使用PowerShell执行此操作至关重要,但是我的研究尚未发现任何问题。 此外,对于理解GPO和PowerShell之间关系的功能方面的任何帮助,或者实际上有助于扩展PowerShell功能(可通过命令行启动(试图使该脚本尽可能自给自足和可重用))的任何帮助,都将非常有用。赞赏。 到目前为止,这里是带有相应任务的脚本。
1.) $cn = [ADSI]"WinNT://Inquisition"
$user = $cn.Create("User","Test")
$user.SetPassword("P@ssword!")
$user.setinfo()
$user.description = "TestUser"
$user.SetInfo()
2.) Get-WmiObject -Class Win32_UserAccount -Filter "name = 'Test'" | Set-WmiInstance -Argument @{PasswordExpires = 0}
3.)?
4.) $Computername = "TEST1"
$sysinfo = Get-WmiObject Win32_ComputerSystem $sysinfo.JoinDomainOrWorkGroup("AWS-TEST")
5.) netsh advfirewall set allprofiles state off
6.) $AUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
$AUSettings.NotificationLevel
$ausettings.NotificationLevel = 1
$ausettings.save()
7.) $path = 'HKCU:\Software\Microsoft\Internet Explorer\Main\'
$name = 'start page'
$value = 'http://www.blueprintcss.org/tests/parts/sample.html'
Set-Itemproperty -Path $path -Name $name -Value $value
8.)?
添加一个名为“ Test”的新用户帐户,其密码为“ P @ ssw0rd!”。
将帐户“测试”的密码设置为永不过期
将用户“测试”添加到本地管理员安全组
将计算机名称设置为“ TEST1”,并将工作组设置为“ AWS-TEST”
关闭Windows防火墙
关闭Windows更新并设置为从不检查更新
将公司网站设置为Internet Explorer中的默认网页
关闭Internet Explorer中的弹出窗口阻止程序
我曾经有过类似的需求,除了我的是要删除本地管理员权限。 这是为我工作的核心。...自从创建新产品以来,请确保为域名,主机名和用户预定义变量。 希望这可以帮助!
$AdminGroup = [ADSI]"WinNT://$HostName/Administrators,group"
$InUser = [ADSI]"WinNT://$DomainName/$User,user"
$Admingroup.Add($InUser.Path)
这是来自https://community.spiceworks.com/topic/post/3297687的单个衬板
([ADSI]"WinNT://<computername>/Administrators,group").Add("WinNT://<domain>/<user>")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.