远程删除和重新映射Sharepoint网络驱动器

时间:2019-07-19 17:04:26

标签: windows powershell sharepoint winrm network-drive

我正尝试将脚本放在一起以远程删除链接到Sharepoint库的一系列映射的网络驱动器,然后在Internet Explorer中更改受信任的站点列表后重新映射它们。

如果没有最终用户的凭据,这似乎也不可行,因为我将尝试将它们映射到他们自己的个人网络驱动器,因此,如果我浪费时间,那也很好知道。

$Computer = Read-Host -Prompt 'Computer Name'
$S = New-PSSession -ComputerName $Computer

Get-Service -Name WinRM -ComputerName '$Computer' | Start-Service -Verbose

Invoke-Command -Session $S -Command {

    Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value '*'

    Get-Process iexplore.exe | Stop-Process

    cd "HKCU:\Software\microsoft\windows\currentversion\Internet Settings"
    cd .\ZoneMap\Domains
    New-Item "venturalaw.sharepoint.com/" -Force -ItemType Directory
    Set-Location "venturalaw.sharepoint.com/"
    New-ItemProperty . -Name https -Value 2 -PropertyType DWORD -Force
    New-ItemProperty . -Name * -Value 2 -PropertyType DWORD -Force
    New-ItemProperty . -Name http -Value 2 -PropertyType DWORD -Force

    Set-Location C:\Windows

    start iexplore.exe

    Start-Sleep -Milliseconds 500

    Get-process iexplore.exe | Stop-Process

    Set-Location c:\windows

    net use m: /del /y
    net use n: /del /y
    net use y: /del /y
    net use r: /del /y
    net use z: /del /y

    net use Y: \\sharepointpath /savecred /persistent:yes
    net use G: \\sharepointpath /savecred /persistent:yes
    net use F: \\appserver\data /persistent:yes
    net use M: \\sharepointpath /savecred /persistent:yes
    net use R: \\sharepointpath /savecred /persistent:yes
    net use V: \\sharepointpath /savecred /persistent:yes
    net use Z: \\sharepointpath /savecred
    net use u: \\appserver\users\%USERNAME% /savecred


 }

预期:驱动器已重新映射,每个人都将我视为英雄

实际:

The network connection could not be found.
    + CategoryInfo          : NotSpecified: (The network con...d not be found.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
    + PSComputerName        : endcomputername

Enter the user name for 'appserver':  
System error 224 has occurred.
    + CategoryInfo          : NotSpecified: (System error 224 has occurred.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
    + PSComputerName        : endcomputername

NotSpecified: (:) [], RemoteException
Access Denied. Before opening files in this location, you must first add the web site to your trusted sites list, browse to the web site, and select the option to login automatically.
NotSpecified: (:) [], RemoteException
The password is invalid for \\appserver\users\%USERNAME%.

0 个答案:

没有答案