【问题标题】:Powershell - Net Use credentials not workingPowershell - 网络使用凭据不起作用
【发布时间】:2020-06-24 13:32:56
【问题描述】:

我想通过powershell自动化网络使用来绑定很多共享驱动。

首先我通过Get-Credentials 获取凭据,然后我想稍后使用这些凭据。

$cred = Get-Credentials -Message "Enter credentials"
net use K: \\192.168.100.50\E$ /user:$cred.username $cred.password

这会引发错误Network password wrong(从德语翻译)

当我这样输入时: net use K: \\192.168.100.50\E$ /user:Admin Adminpassword

有效吗?当我用明文密码替换$cred.password 并且只使用用户名变量时,它仍然显示Network password wrong

这里有什么冲突?

【问题讨论】:

    标签: powershell variables net-use


    【解决方案1】:

    使用 powershell 来执行此操作,因为 Get-Credentials 将您的数据存储为安全字符串,net use 无法使用它。

     $cred = Get-Credentials -Message "Enter credentials"
     New-PSDrive -Name K -PSProvider FileSystem -Root "ComputerName\FilePath" -Persist -Credential $cred
    

    【讨论】:

    • 哦,谢谢!我在某处读到 new-psdrive 不会在资源管理器中添加驱动器,但仅适用于 powershell,这很棒
    • @FlyingThunder 它使用参数-Persist在资源管理器中添加驱动器
    猜你喜欢
    • 1970-01-01
    • 2016-07-12
    • 1970-01-01
    • 1970-01-01
    • 2021-11-08
    • 1970-01-01
    • 2013-09-09
    • 1970-01-01
    相关资源
    最近更新 更多