Showing posts with label powershell. Show all posts
Showing posts with label powershell. Show all posts

Thursday, 22 August 2013

Powershell: Create Folder/Directory if doesn't exists

Simple script for creating new folders.

# Create folder if it doesn't exists
function CreteFolder([String]$folderPath)
{
if ((Test-Path $folderPath) -ne $True)
        { New-Item $folderPath -type directory }
}

Thursday, 18 July 2013

Powershell: How to get members of AD security group

all - AD security group

Get-ADGroupMember all 

Displays only "usernames":
Get-ADGroupMember all | Select SamAccountName

Snippet for Iterating through all users

$Users=Get-ADGroupMember all | Select SamAccountName

foreach ($User in $Users)
{
Write-Host $User.SamAccountName

}