0
votes

So, i'm trying to run this SPO PowerShell script that microsoft provides in this link: https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/export-spouserinfo?view=sharepoint-ps on the "example 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." 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?

Here is the code i'm using:

    $sites = Get-SPOSite -IncludePersonalSite $true
$user = "[email protected]"
foreach ($site in $sites)
{
Export-SPOUserInfo -LoginName $user -site $site.Url -OutputFolder
"D:"
}

Thanks in advance!

1

1 Answers

0
votes

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 = "[email protected]"
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

about_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.