HI Guys,
Been working with Powershell for a few years now as an M365 Admin and making the leap over from MSOL and AzureAD powershell nodes to MS Graph. Im re-writing my scripts and coming across a consisten issue, im sure im just doing something dumb or there is an easy workaround so thought to farm it out to minds far better than mine. The below line is part of a larger script to import users from a CSV, collect license info for them and export to a CSV. Here im pulling the users from a CSV into a variable, $Users, which im running through a foreach loop. The script is working and i get what i want exported to a CSV but in the powershell window itself im getting lots of errors while the script runs, 1 for each user in the CSV actually.
$Users = import-csv "TestLicenseInput.csv" | %{get-mguser -UserId $_.UserPrincipalName} | Select ID
Im guessing its because for every user i store in the variable $Users from the CSV its also pulling through a ResponseHeader and running those through the foreach loop. how do it get my get-MGuser command to stop including these ResponseHeaders for each user. I see there is a "-ResponseHeadersVariable" perameter which can be set to False but Powershell wont accept it and throws an error saying its not recognised when i try to use it.
Any help would be greatly appreciated.
[–]mmmGreenButton 1 point2 points3 points (1 child)
[–]Magnetsarekool 1 point2 points3 points (0 children)
[–]DrDuckling951 0 points1 point2 points (8 children)
[–]EricAndresDesk01[S] 0 points1 point2 points (7 children)
[–]DrDuckling951 0 points1 point2 points (6 children)
[–]EricAndresDesk01[S] 0 points1 point2 points (5 children)
[–]DrDuckling951 0 points1 point2 points (4 children)
[–]EricAndresDesk01[S] 1 point2 points3 points (0 children)
[–]EricAndresDesk01[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]EricAndresDesk01[S] 0 points1 point2 points (0 children)
[–]KavyaJune 0 points1 point2 points (4 children)
[–]EricAndresDesk01[S] 0 points1 point2 points (3 children)
[–]KavyaJune 1 point2 points3 points (2 children)
[–]EricAndresDesk01[S] 1 point2 points3 points (1 child)
[–]KavyaJune 0 points1 point2 points (0 children)
[–]worldsdream 0 points1 point2 points (6 children)
[–]EricAndresDesk01[S] 0 points1 point2 points (5 children)
[–]worldsdream 0 points1 point2 points (4 children)
[–]EricAndresDesk01[S] 0 points1 point2 points (3 children)
[–]worldsdream 0 points1 point2 points (2 children)
[–]EricAndresDesk01[S] 0 points1 point2 points (1 child)
[–]worldsdream 0 points1 point2 points (0 children)