简体   繁体   English

SharePoint在线执行PowerShell脚本出错

[英]Error when executing PowerShell script for SharePoint Online

So, i'm trying to run this SPO PowerShell script that microsoft provides in this link: https://learn.microsoft.com/en-us/powershell/module/sharepoint-online/export-spouserinfo?view=sharepoint-ps on the "example 2".所以,我正在尝试运行微软在此链接中提供的 SPO PowerShell 脚本: https://learn.microsoft.com/en-us/powershell/module/sharepoint-online/export-spouserinfo?view=sharepoint-ps关于“示例 2”。 However, when i try to run the script on PowerShell ISE, i get the following error: "Parameter missing for 'Output Folder' argument. Specify a 'System.String' type parameter and try again."但是,当我尝试在 PowerShell ISE 上运行脚本时,出现以下错误:“‘输出文件夹’参数缺少参数。指定‘System.String’类型参数并重试。” I tried to change the arguments, input my site collection, creating a.csv file on the folder, but nothing changes this error message, what am i doing wrong?我试图更改 arguments,输入我的网站集,在文件夹中创建一个 .csv 文件,但没有任何更改此错误消息,我做错了什么?

Here is the code i'm using:这是我正在使用的代码:

    $sites = Get-SPOSite -IncludePersonalSite $true
$user = "xxxxxx@domain.com"
foreach ($site in $sites)
{
Export-SPOUserInfo -LoginName $user -site $site.Url -OutputFolder
"D:"
}

Thanks in advance!提前致谢!

Writing to the root of a drive is really not a best practice.写入驱动器的根目录确实不是最佳做法。 Always use a folder of the root, unless there is a very valid reason to put a file there.始终使用根文件夹,除非有非常正当的理由将文件放在那里。 Yet, that is not your use case as presented.然而,这不是您介绍的用例。

$sites = Get-SPOSite -IncludePersonalSite $true
$user = "xxxxxx@domain.com"
foreach ($site in $sites)
{
    Export-SPOUserInfo -LoginName $user -site $($site.Url) -OutputFolder 'D:\SPOSiteData'
}

Your string must be all on one line if not properly terminated for multi-line.如果多行没有正确终止,您的字符串必须全部在一行上。 For example, using PowerShell Splatting例如,使用 PowerShell Splatting

about_Splatting - PowerShell | 关于_Splatting - PowerShell | Microsoft Docs 微软文档

$ExportSPOUserInfoSplat = @{
    LoginName    = $user 
    site         = $($site.Url)
    OutputFolder = 'D:\SPOSiteData'
}
Export-SPOUserInfo @ExportSPOUserInfoSplat

Te line wrapping, which it seems you copied and pasted, is that way because of page space not a code requirement.您似乎复制并粘贴了换行,因为页面空间不是代码要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM