0

我正在处理 PowerShell 脚本,我需要定义位置变量来对用户的安全组进行一些更改。我将它们定义如下,它们可以工作。

我需要这些单独的变量来根据它们工作的位置运行其他脚本。但是我如何干净地做到这一点?有人看了我的代码,说它看起来很乱,我需要清理它或者可能使它成为一个衬垫?

谢谢

$Ints = Get-ADUser -Filter * -Properties * | Where-Object -Property "Title" -like "Floor Workers*"
    
    $APPInts = $Ints | Where-Object Office -EQ "Appa"
    $RITInts = $Ints | Where-Object Office -EQ "Rita"
    $GAMInts = $Ints | Where-Object Office -EQ "Gramma"
    $FOLInts = $Ints | Where-Object Office -EQ "Fola"
    $MITInts = $Ints | Where-Object Office -EQ "Mita"
    $CONInts = $Ints | Where-Object Office -EQ "Conroja"
    $ASRInts = $Ints | Where-Object Office -EQ "Asra"
    $MILInts = $Ints | Where-Object Office -EQ "Milata"
    $UMLInts = $Ints | Where-Object Office -EQ "Umla"
    $RMTInts = $Ints | Where-Object Office -Like "*Remote*"
4

0 回答 0