add script
This commit is contained in:
24
Windows/Test-GroupMember.ps1
Normal file
24
Windows/Test-GroupMember.ps1
Normal file
@@ -0,0 +1,24 @@
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Name,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Group
|
||||
)
|
||||
|
||||
#Vérifier si le groupe existe et si l'utilisateur est membres
|
||||
try {
|
||||
$GroupMembers = Get-LocalGroupMember -Group $Group -ErrorAction Stop
|
||||
if ($GroupMembers -match $Name) {
|
||||
#Si oui retourner OUI
|
||||
return $true
|
||||
}
|
||||
else {
|
||||
#Sinon retourner NON
|
||||
return $false
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "Group doesn't exist"
|
||||
}
|
Reference in New Issue
Block a user