无法在Azure Webjob中运行Powershell脚本

问题描述 投票:0回答:1

我正在尝试从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
azure powershell azure-webjobs
1个回答
0
投票
根据我的测试,如果我们要将SharePoint网站与Azure Powershell webjob连接,请参考以下步骤

    本地安装PnP模块
  • Install-Module SharePointPnPPowerShellOnline
    1. 通过kudu将PnP模块上传到Azureenter image description hereenter image description hereenter image description here
    2. 脚本

    $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

    enter image description here
  • © www.soinside.com 2019 - 2024. All rights reserved.