我需要能够传递凭据,我拥有远程计算机的本地管理员凭据。
我一次只需要瞄准一台机器,这将在函数中手动指定,并且IP将被分配为$Global:var
我可以使用WMI-GetObject并停止/启动打印机假脱机服务,但在不使用invoke传递凭据时找不到删除远程文件的方法,invoke不起作用,因为WinRM未启用(策略无法启用)
感谢您所能提供的任何帮助。
我有一个测试设置,我可以根据需要进行测试
另外,让我知道这是否更适合SuperUser而不是StackOverflow
发布于 2019-08-08 22:45:41
最后,我无法在powershell本身中找到解决方案,所以我默认使用一个位于同一位置的批处理文件来处理windows文件操作,并使用
start-process -Wait "cmd.exe" "/c c:\powershell\clearspool.bat"批处理文件在下面
@ECHO off
rem Set up the remote server ip
set User=administrator
set /p Server=Enter Server IP:
set /p Password=Enter Admin Password:
rem Mount the remote path
net use \\%Server%\c$\Windows\System32\spool %Password% /USER:%User%
rem Delete a file
del /S /F \\%Server%\c$\Windows\System32\spool\PRINTERS
rem Unmount the remote path
net use \\%Server%\c$\Windows\System32\spool /delete https://stackoverflow.com/questions/57295038
复制相似问题