如何使用New匿名连接powershell中的SMB共享?
我尝试过省略-Credential参数,但这似乎使用了当前登录的用户。当我使用域帐户进行测试时,这是可行的,但问题是,对于正常操作,当前登录的用户是本地信息亭用户,用于分配访问权限,而域文件服务器不识别。
我也尝试使用以下方法,但是它提示用户输入。因为这是作为后台操作的计划任务运行--这是不可接受的。
$Credentials = Get-Credential -UserName 'NTAUTHORITY\Anonymous Logon'
New-PSDrive -ErrorAction Stop -PSProvider "FileSystem" -Root "$RemoteFolder" -Name "$RemoteDriveLetter" -Credential $Credentials -Persist -Scope Global | Out-Null我已经启用了文件服务器上的本地安全策略选项,用于“网络访问:让每个人的权限应用于匿名用户”。
如何利用New-PSDrive的“匿名”用户连接?
-编辑--
我也试过这个
$Credentials = [pscredential]::Empty
New-PSDrive -ErrorAction Stop -PSProvider "FileSystem" -Root "$RemoteFolder" -Name "$RemoteDriveLetter" -Credential $Credentials -Persist -Scope Global | Out-Null然而,产出是:
>> TerminatingError(New-PSDrive): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The specified network password is not correct"
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The specified network password is not correct发布于 2022-08-24 16:45:22
匿名挂载使用“空”用户和密码作为凭据块,因此您也可以这样做。
这对我有效,并允许在共享上创建文件:
$User = " " # Create 'empty' username
$PWord = ConvertTo-SecureString -String " " -AsPlainText -Force
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
New-PSDrive -PSProvider "FileSystem" -Root "$RemoteFolder" -Name "$RemoteDriveLetter" -Credential $Credentials -Persist -Scope Global | Out-Nullhttps://stackoverflow.com/questions/73476409
复制相似问题