When I run the cmdlet Get-CMDistributionPointInfo | select ServerName to get a list of SCCM distribution points (DPs) by itself, I will get the following results example:
etc.
When I run the for loop below, I can do a write-host and it will list the DPs, but it does so several times for each DP result, so obviously the code is not correct. Also, if I do a write-host in that for loop, it will show the server name, but if I do a message box, it will not show one server after the next.
Ultimately, what I am trying to do is after it gets each DP server, to then create a directory on a specific drive on that server. That part I can handle, but I am having issues with the for loop just displaying the server in a message box and then the next one and then so on.
Any help would be greatly appreciated!
$GET_DP = Get-CMDistributionPointInfo | select ServerName foreach($GET_DPS in $GET_DP) { if($GET_DPS -ne $GET_DP) { Write-Output ($GET_DP) [System.Windows.MessageBox]::Show($GET_DP) } Else { } }