我正在尝试从Azure应用服务中运行的PowerShell作业连接到共享站点,但是,我总是收到以下错误
Import-Module : The Win32 internal error "The handle is invalid" 0x6 occurred
while setting character attributes for the console output buffer. Contact
Microsoft Customer Support Services.
At D:\home\site\wwwroot\test.ps1:2 char:1
+ Import-Module 'D:\home\site\wwwroot\SharePointPnPPowerShellOnline\3.1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Import-Module], HostEx
ception
+ FullyQualifiedErrorId : SetConsoleTextAttribute,Microsoft.PowerShell.Com
mands.ImportModuleCommand
Install-Module SharePointPnPPowerShellOnline
- 通过kudu将PnP模块上传到Azure
- 脚本
$ProgressPreference="SilentlyContinue" Import-Module 'D:\home\site\wwwroot\SharePointPnPPowerShellOnline\3.18.2002.0\SharePointPnPPowerShellOnline' -DisableNameChecking $name = 'username' $password = 'password' $secpasswd = ConvertTo-SecureString $password -AsPlainText -Force $mycreds = New-Object System.Management.Automation.PSCredential ($name, $secpasswd) Connect-PnPOnline -Url https://hanxia.sharepoint.com/ -Credentials $mycreds Get-PnPList