Passing Array Variable from CSV to Identity for Get-SPOSite

Welcome Forums General PowerShell Q&A Passing Array Variable from CSV to Identity for Get-SPOSite

Viewing 2 reply threads
  • Author
    Posts
    • #194450
      Participant
      Topics: 9
      Replies: 11
      Points: 151
      Rank: Participant

      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:

      Title          Owner                  StorageUsage Current Url -----          -----                  ------------------- --- Martin, R 0240357@domain.com 61 https://domain-my.sharepoint.com/personal/0240357_doma...[/crayon]

      These two options below do not work.

      foreach ($user in $users){Get-SPOSite -Identity https://domain-my.sharepoint.com/personal/"$user"_domain_com | Select-Object Title, Owner, StorageUsageCurrent, Url}[/crayon]

      or

      [/crayon]

      Both of the above one liners will give me the same error:

      At line:1 char:56 + ... Each-Object{Get-SPOSite -Identity https://domain-my.sharepoint.co ... +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo          : NotSpecified: (:) [Get-SPOSite], ServerException + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.GetSite[/crayon]

      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

    • #194456
      Participant
      Topics: 13
      Replies: 1753
      Points: 3,136
      Helping Hand
      Rank: Community Hero

      The for loop is references $User, which is basically the row that is being processed, so you need to tell it what Property (i.e. Column) you want. With the error message, it appears to be User, so it would $user.User:

    • #194495
      Participant
      Topics: 9
      Replies: 11
      Points: 151
      Rank: Participant

      Thank you Rob,

      This worked just like I needed it to.

Viewing 2 reply threads
  • The topic ‘Passing Array Variable from CSV to Identity for Get-SPOSite’ is closed to new replies.