Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

IF Statement help - PowerShell

$
0
0

Hi,

I am trying to remove and add a group if a user is a member but the IF STATEMENT is not quite there.  It does not loop through every user in the spreadsheet.  Any assistance would be much appreciated, it's almost there:

$csv = Import-Csv "c:\SCRIPTS\users.csv"

Function switch-Office {
remove-adgroupmember -Identity "appmsoffice2003" -Member $sam -Confirm:$false
Add-ADGroupMember -Identity "appmsoffice2010" -Members $sam -Confirm:$false
}


Function switch-Outlook {
remove-adgroupmember -Identity "appmsoutlook2003" -Member $sam -Confirm:$false
Add-ADGroupMember -Identity "appmsoutlook2010" -Members $sam -Confirm:$false
}


foreach($row in $csv)
{
$sam = $row.sam

GET-QADUSER $SAM

IF (get-qaduser $SAM -MEMBEROF 'AppMSOffice2003')
{switch-office}
IF (get-qaduser $SAM -MEMBEROF 'AppMSOutlook2003') {
switch-office
}
}

I just need the IF loop tweaking, thanks, Matt.


Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>