从C#代码运行ps1时出错(Office 365) [英] Error running ps1 from c# code (Office 365)
问题描述
使用office365中C#代码中的ps1文件创建共享点站点时.这个错误即将到来 在模块"Microsoft.Online.SharePoint.PowerShell"中找到"connect-sposervice"命令,但无法加载该模块.有关更多信息,请运行导入模块Microsoft.Online.SharePoint.PowerShell".
When creating the sharepoint site using ps1 file from C# code in office365. This error is coming The 'connect-sposervice' command was found in the module 'Microsoft.Online.SharePoint.PowerShell', but the module could not be loaded. For more information, run 'Import-Module Microsoft.Online.SharePoint.PowerShell'.
直接在powershell中运行ps1可以得到所需的结果,但不能使用c#代码正常工作
Running the ps1 directly in powershell is giving the desired result, but not working properly using c# code
推荐答案
我遇到了同样的问题,并以此方式解决了该问题:
I had the same problem and solve it this way:
查找文件
C:\ Program Files \ SharePoint Online命令行管理程序\ Microsoft.Online.SharePoint.PowerShell \ Microsoft.Online.SharePoint.PowerShell.psd1
并更改此行
# Processor architecture (None, X86, Amd64, IA64) required by this module
ProcessorArchitecture = 'Amd64'
为此:
# Processor architecture (None, X86, Amd64, IA64) required by this module
ProcessorArchitecture = 'X86'
我不知道这是否是一个很好的解决方案,但是对我来说有效. 任何建议都很好
I don't know if it's a good solution, but it's works for me. Any suggestion is wellcome
这篇关于从C#代码运行ps1时出错(Office 365)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!