Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Get-Adgroup + variable

$
0
0

Hi guys, i need your help. I would like to create a simple scritp to optain a groupname if it exists. I did it:

Import-Module ActiveDirectory 
$today = Get-Date -f dd.MM.yyyy_ore_HH_mm 
$srvname = Read-Host 'Server Name?' 
$path = "\\tstsrv001\c$\tmp\$srvname\" 
if(!(Test-Path -Path $path )){ 
    New-Item -ItemType directory -Path $path 

$group = Get-ADGroup -Filter {name -like "*$srvname*"} | select SamAccountName 
Out-File -FilePath "$path\$today.txt" -append

The only thing i need are the groups name where $srvname is present.

Thanks!!!!!!



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>