Untitled

mail@pastecode.io avatar
unknown
plain_text
24 days ago
737 B
1
Indexable
Never
# 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: $_"
}
Leave a Comment