Untitled

 avatar
unknown
plain_text
a year ago
737 B
5
Indexable
# Path to the CSV file containing computer names
$csvFilePath = "c:\dev\zoma.csv"
$groupName = "SGG-GPF-ApplockerAppcontrol-DisableAppLocker"

try {
    # Import CSV file
    $computers = Import-Csv $csvFilePath
    foreach ($computer in $computers) {
        $computerName = $computer.Name
        # Check if computer is part of the specified group
        if (Get-ADComputer -Filter {Name -eq $computerName} | Get-ADPrincipalGroupMembership | Where-Object {$_.Name -eq $groupName}) {
            Write-Host "$computerName is part of the $groupName group."
        } else {
            Write-Host "$computerName is not part of the $groupName group."
        }
    }
} catch {
    Write-Host "An error occurred: $_"
}
Editor is loading...
Leave a Comment