Arrays .Indexof()

Microsoft Teams Remote Powershell Workarounds


Remote powershell sessions to the Teams Infrastructure have a habit of disconnecting at the most inopportune moments.
Usually whilst in the midst of a foreach loop.
To recover from this, the .IndexOf() method is most invaluable.

Usage is as follows:

$User = get-aduser <samaccountname>
$ArrayName.IndexOf($User)

Will return the index of the array where the object can be found. The loop can then be continued with the following command

for ($n = <index>; $n -le <ArraySize>; $n++)
     {
          Some Powershell commands here......
     }

No comments:

Post a Comment