[英]Run a script after a Windows 10 (non-Domain) Reset to enable RDP
For the Reset function, I go to Settings > Updates and Security > Recovery > Reset this PC.对于重置 function,我 go 到设置 > 更新和安全 > 恢复 > 重置这台电脑。 So this is a choice that I make, and on that basis I want to choose for that system to run a script after the Reset - and we know that should be possible as we can create completely customised Windows installation ISOs that install apps and Features in a clean state, so can someone tell me how to do a quite simple things - to just get Windows to run a PowerShell script after that Reset?
所以这是我做出的选择,在此基础上,我想为该系统选择在重置后运行脚本 - 我们知道这应该是可能的,因为我们可以创建完全自定义的 Windows 安装 ISO,在其中安装应用程序和功能一个干净的 state,所以有人能告诉我如何做一件非常简单的事情——让 Windows 在重置后运行 PowerShell 脚本吗?
Actually, I only want to run a couple of lines:实际上,我只想运行几行:
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
ie This will enable RDP and allow me to connect remotely and continue the configuration without having to plug in a monitor and keyboard and mouse all just to run the above two commands.即这将启用 RDP 并允许我远程连接并继续配置,而无需插入显示器和键盘和鼠标,所有这些都只是为了运行上述两个命令。 As per title, this is a non-Domain scenario so accessing the system as Domain Admin is not possible (and really a Domain should not be necessary, these are my systems on my local.network).
根据标题,这是一个非域场景,因此无法以域管理员身份访问系统(实际上不需要域,这些是我在 local.network 上的系统)。
The other reason that should make all of the above completely possible is that performing a Reset is not an absolute reset as it retains user information (my main user is still there with the password intact), so just enabling RDP would make everything possible post-Reset.应该使上述所有内容完全成为可能的另一个原因是,执行重置不是绝对重置,因为它保留了用户信息(我的主要用户仍然在那里,密码完好无损),所以只要启用 RDP 就可以使一切成为可能重启。
For reference, nothing in the following have helped me to achieve this goal so far: Run a powershell script on a remote system with elevated permissions to enable remoting https://interfacett.com/blogs/how-to-remotely-enable-and-disable-rdp-remote-desktop作为参考,到目前为止,以下内容都没有帮助我实现这个目标: 在具有提升权限的远程系统上运行 powershell 脚本以启用远程处理https://interfacett.com/blogs/how-to-remotely-enable-and -禁用-rdp-远程桌面
The easiest way to do this is to download PStools from Microsoft and use psexec
to give yourself remote access:最简单的方法是从 Microsoft 下载 PStools 并使用
psexec
为自己提供远程访问权限:
psexec \\machinename reg add hklm\system\currentcontrolset\control\terminal server /f /v fDenyTSConnections /t REG_DWORD /d 0
psexec \\machinename netsh firewall set service remoteadmin enable
psexec \\machinename netsh firewall set service remotedesktop enable
psexec will let you supply credentials with -u
and -p
psexec 将允许您使用
-u
和-p
提供凭据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.