Good Morning Everyone,
I’m currently trying to find out information about specific user’s one drive folders.
If I test with just my username, it works just fine. When I attempt to pass the variable through from a CSV file, it keeps the array tags around the variable, and fails because that website is not found.
This works:
Get-SPOSite -Identity https://domain-my.sharepoint.com/personal/0240357_domain_com | Select-Object Title, Owner, StorageUsageCurrent, Url</code>
<code>
Title Owner StorageUsage Current Url</code>
<code>----- ----- ------------------- ---</code>
<code>Martin, R 0240357@domain.com 61 https://domain-my.sharepoint.com/personal/0240357_doma...
These two options below do not work.
$users = import-csv C:\scripts\names.csv</code>
<code>foreach ($user in $users){Get-SPOSite -Identity https://domain-my.sharepoint.com/personal/"$user"_domain_com | Select-Object Title, Owner, StorageUsageCurrent, Url}
or
import-csv C:\Scripts\names.csv | ForEach-Object{Get-SPOSite -Identity https://domain-my.sharepoint.com/personal/"$user"_domain_com | Select-Object Title, Owner, StorageUsageCurrent, Url}
Both of the above one liners will give me the same error:
Get-SPOSite : Cannot get site https://domain-my.sharepoint.com/personal/@{User=0240357}_domain_com.</code>
<code>At line:1 char:56</code>
<code>+ ... Each-Object{Get-SPOSite -Identity https://domain-my.sharepoint.co ...</code>
<code>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</code>
<code>+ CategoryInfo : NotSpecified: (:) [Get-SPOSite], ServerException</code>
<code>+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.GetSite
Is there anyway for me to pass that variable and also strip off the array tags so that it sits nicely inside the URL like I need it to?
Thank you for your time,
Rob Martin