Powershell, help comparing 2 variables values RRS feed

  • Question

  • Hi everyone

    I'm a powershell noob and im trying to create a script that can help me compare some citrix profile folders that are name SAM_xxxxx+x+xx+xxx along those lines with our current users in AD, in my mind a pretty simple script, however i can't make it work.

    $ADusers = Get-ADUser -SearchBase “OU=Users,OU=xxx,DC=xx,DC=xxx” -Filter * | select SamAccountName | Sort-Object SamAccountName
    $folders = get-childitem -Path \\xxxxx\xxxx -Directory
    $temp = "false"

    foreach ($folder in $folders)
    foreach ($i in $ADuser.samaccountname)
    if($folder.Name -like $i){
    $temp = "true"
    else {
    $temp = "false"
    if($temp -eq "true"){
    write $i

    Pretty sure its my $ -like $i statement thats wrong, however i can't figure out how to fix it.

    I also thought about deleting everything after _ in the $ but i couldn't get that to work either

    I would be very gratefull if anyone could help me shed some light on this problem.

    Thanks in advance, Hidin

    Monday, February 17, 2020 2:40 PM

All replies