Monday, June 27, 2016

Scheduling Job using Powershell


Sometime we need some job or trigger to execute at specific time. We can trigger this by using powershell cmdlets. With new version of Powershell, we get cmdlets for scheduling triggers at time required. Job scheduling allows you to schedule execution of a windows powershell background job for a later time. First thing you do is create a job trigger. This defines when the job will execute.

You need to import PSScheduledJob first then associated cmdlets would be available.

You can import module by command
Import-Module PSScheduledJob

and check associated cmdlets by

Get-Command -Module *PSScheduled*

For creating job, you need to use New-JobTrigger(trigger) cmdlet and need to register the job with specific schedule and command.

$Newtrig=New-JobTrigger -Daily -At 7PM   # This is new trigger which we can use while registering Job

Register-ScheduledJob -Name Copyfile -trigger $Newtrig -ScriptBlock {Copy-Item D:\Shanky\ "\\10.89.0.9\Shanky\Daily" -Recurse}

Once the trigger has fired and the job has run, You can work with it the same way you do with regular background jobs.

Get-Job -Name Copyfile | Receive-Job

You can start a scheduled job manually, rather than waiting for the trigger to fire:

Start-job -DefinitionName Copyfile

Other cmdlets available from PSScheduledJob

Friday, June 17, 2016

DHCP Scope Monitoring



Previously we have face many issue with client on able to get IP because of DHCP scope gets full. We can take help of new DHCP module to monitor all scope on DHCP server and provides us mail.

Below Script will monitor all scopes in DHCP server using Get-DhcpServerv4ScopeStatistics and will mail to your email address. You can set your threshold on variable $threshold, which I have set it to 90.

Script can be scheduled for every 15 minutes or 30 minutes according to your preferences and critical scope.

Import-Module DHCP

$threshold = 90
$email_to = "admin_group@shanky.com”
$email_from = “Monitoring@shanky.com”
$email_server = “10.1.36.9”
$scopes = Get-DhcpServerv4ScopeStatistics

foreach ($scope in $scopes) {
    if($scope.PercentageInUse -gt $threshold){
        $email_body = “Scope: $($scope.ScopeId) – pool IPs in use is $([math]::round($scope.PercentageInUse, 0))% on $(hostname)”
        Send-MailMessage -To $email_to -From $email_from -SmtpServer $email_server -Subject “Scope threshold exceeded – $($scope.ScopeId)” -Body $email_body
    }
}



Saturday, June 11, 2016

History / Version of Powershell

PowerShell 1.0

PowerShell 1.0 was released in November 2006 for Windows XP SP2, Windows Server 2003 and Windows Vista. It is an optional component of Windows Server 2008.

PowerShell 2.0

Windows PowerShell ISE v2.0, an integrated development environment for PowerShell scripts
PowerShell 2.0 is integrated with Windows 7 and Windows Server 2008 R2 and is released for Windows XP with Service Pack 3, Windows Server 2003 with Service Pack 2, and Windows Vista with Service Pack 1.

PowerShell V2 includes changes to the scripting language and hosting API, in addition to including more than 240 new cmdlets.

New features of PowerShell 2.0 include:


  • PowerShell Remoting: Using WS-Management, PowerShell 2.0 allows scripts and cmdlets to be invoked on a remote machine or a large set of remote machines.
  • Background Jobs: Also called a PSJob, it allows a command sequence (script) or pipeline to be invoked asynchronously. Jobs can be run on the local machine or on multiple remote machines. An interactive cmdlet in a PSJob blocks the execution of the job until user input is provided.
  • Transactions: Enable cmdlet and developers can perform transactional operations. PowerShell 2.0 includes transaction cmdlets for starting, committing, and rolling back a PSTransaction as well as features to manage and direct the transaction to the participating cmdlet and provider operations. The PowerShell Registry provider supports transactions.
  • ScriptCmdlets: These are cmdlets written using the PowerShell scripting language. The preferred name for script cmdlets is now Advanced Functions.[citation needed]
  • SteppablePipelines: This allows the user to control when the BeginProcessing(), ProcessRecord() and EndProcessing() functions of a cmdlet are called.
  • Modules: This allows script developers and administrators to organize and partition PowerShell scripts in self-contained, reusable units. Code from a module executes in its own self-contained context and does not affect the state outside the module. Modules can define a restricted runspace environment by using a script. They have a persistent state as well as public and private members.
  • Data Language: A domain-specific subset of the PowerShell scripting language that allows data definitions to be decoupled from the scripts and allows localized string resources to be imported into the script at runtime (Script Internationalization).
  • Script Debugging: It allows breakpoints to be set in a PowerShell script or function. Breakpoints can be set on lines, line & columns, commands and read or write access of variables. It includes a set of cmdlets to control the breakpoints via script.
  • Eventing: This feature allows listening, forwarding, and acting on management and system events. Eventing allows PowerShell hosts to be notified about state changes to their managed entities. It also enables PowerShell scripts to subscribe to ObjectEvents, PSEvents, and WmiEvents and process them synchronously and asynchronously.
  • Windows PowerShell Integrated Scripting Environment (ISE): PowerShell 2.0 includes a GUI-based PowerShell host that provides integrated debugger, syntax highlighting, tab completion and up to 8 PowerShell Unicode-enabled consoles (Runspaces) in a tabbed UI, as well as the ability to run only the selected parts in a script.
  • Network File Transfer: Native support for prioritized, throttled, and asynchronous transfer of files between machines using the Background Intelligent Transfer Service (BITS).
  • New Cmdlets: Including Out-GridView, which displays tabular data in the WPF GridView object.
  • New Operators: -Split, -Join, and Splatting (@) operators.
  • Exception Handling with Try-Catch-Finally: Unlike other .NET languages, this allows multiple exception types for a single catch block.
  • Nestable Here-Strings: PowerShell Here-Strings have been improved and can now nest.
  • Block Comments: PowerShell 2.0 supports block comments using <# and #> as delimiters.
  • New APIs: The new APIs range from handing more control over the PowerShell parser and runtime to the host, to creating and managing collection of Runspaces (RunspacePools) as well as the ability to create Restricted Runspaces which only allow a configured subset of PowerShell to be invoked. The new APIs also support participation in a Windows PowerShell managed transaction.


PowerShell 3.0

PowerShell 3.0 is integrated with Windows 8 and with Windows Server 2012. Microsoft has also made PowerShell 3.0 available for Windows 7 with Service Pack 1, for Windows Server 2008 with Service Pack 1, and for Windows Server 2008 R2 with Service Pack 1.

PowerShell 3.0 is part of a larger package, Windows Management Framework 3.0 (WMF3), which also contains the WinRM service to support remoting. Microsoft made several Community Technology Preview releases of WMF3. An early community technology preview 2 (CTP 2) version of Windows Management Framework 3.0 was released on 2 December 2011. Since then, updated versions have been shipped in the Windows 8 and Server 2012 beta and release candidate versions.[citation needed]

New features in PowerShell 3.0 include:


  • Scheduled jobs: Jobs can be scheduled to run on a preset time and date.
  • Session connectivity: Sessions can be disconnected and reconnected. Remote sessions have become more tolerant of temporary network failures.
  • Improved code writing: Code completion (IntelliSense) and snippets are added. PowerShell ISE allows users to use dialog boxes to fill in parameters for PowerShell cmdlets.
  • Delegation support: Administrative tasks can be delegated to users who do not have permissions for that type of task, without granting them perpetual additional permissions.
  • Help update: Help documentations can be updated via Update-Help command.
  • Automatic module detection: Modules are loaded implicitly whenever a command from that module is invoked. Code completion works for unloaded modules as well.
  • New commands: Dozens of new modules were added, including functionality to manage disks, volumes, firewalls, network connections and printer management, previously performed via WMI.[further explanation needed]


PowerShell 4.0

PowerShell 4.0 is integrated with Windows 8.1 and with Windows Server 2012 R2. Microsoft has also made PowerShell 4.0 available for Windows 7 SP1, Windows Server 2008 R2 SP1 and Windows Server 2012.

New features in PowerShell 4.0 include:

  • Desired State Configuration: Declarative language extensions and tools that enable the deployment and management of configuration data for systems using the DMTF management standards and WS-Management Protocol.
  • New Default Execution Policy: On Windows Servers, the default execution Policy is now RemoteSigned
  • Save-Help: Help can now be saved for modules that are installed on remote computers.
  • Enhanced debugging: The debugger now supports debugging workflows, remote script execution and preserving debugging sessions across PowerShell session reconnections.
  • -PipelineVariable switch: A new ubiquitous parameter to expose the current pipeline object as a variable for programming purposes.
  • Network diagnostics to manage physical and Hyper-V's virtualized network switches.
  • Where and ForEach method syntax provides an alternate method of filtering and iterating over objects.

PowerShell 5.0

An initial public preview of PowerShell 5.0 was made available with Windows Management Framework 5.0 (WMF5) on April 3, 2014. Key features include OneGet PowerShell cmdlets to support Chocolatey's repository-based package management and extending support for switch management to layer 2 network switches.

On November 18, 2014, Microsoft released the November 2014 Preview of the Windows Management Framework Core 5.0 package. Improvements were made to Desired State Configuration (DSC), OneGet, PowerShellGet, PowerShell class definitions, and debugging for PowerShell background jobs and PowerShell runspaces in remote processes. On August 31, 2015, Microsoft released a further preview of its Windows Management Framework (WMF) 5.0 solution billed as "production ready", and which will be fully supported until 90 days after WMF 5.0 RTM.

PowerShell 5.0 was released to web on December 16, 2015, only to be retracted on December 23, because of an unresolved bug. Once the bug was fixed, PowerShell 5.0 was re-released 70 days later on February 24, 2016.

New features in PowerShell 5.0 include:


  • PowerShell class definitions (properties, methods)
  • PowerShell .NET Enumerations
  • Debugging for PowerShell Runspaces in remote processes
  • Debugging for PowerShell Background Jobs
  • Desired State Configuration (DSC) Local Configuration Manager (LCM) version 2.0
  • DSC partial configurations
  • DSC Local Configuration Manager meta-configurations
  • Authoring of DSC resources using PowerShell classes

Reference - Wiki

Powershell CMDLETS for DHCP



DHCP is very important technology in any organisational infrastructure. Many administrators finds very difficultly in managing DHCP and DHCP scopes in large farm.
There are many commands for managing DHCP which are used by administrators and networks guys, but still there is no willing results which can be retrieved from this commands.

Like "netsh dhcp server show scope"

We need DHCP cmdlet to be available in order to manage DHCP. By default, the DHCP module is not loaded in Powershell. We need to install and import the DHCP module before we can use it.

It is available from Windows server 2012 and windows server 2012R2 onwards.

Before you use any DHCP cmdlets, you need to import DHCP module

Import-Module DhcpServer

Note - You have to install DHCP role with management tools, to get this module on system. It can be also installed by PS command for Adding Windows Featured

Add-WindowsFeature -Name DHCP -IncludeManagementTools

The following new DHP PowerShell cmdlets have been introduced in Windows Server 2012 R2:

Add-DhcpServerSecurityGroup : Adds security groups to a DHCP server.
Add-DhcpServerv4MulticastExclusionRange: Adds a range of addresses to exclude from a multicast scope.
Add-DhcpServerv4MulticastScope: Adds a multicast scope on the DHCP server.
Get-DhcpServerDnsCredential: Gets an account that the DHCP Server service uses to register or deregister client records on a DNS server.
Get-DhcpServerv4MulticastExclusionRange: Retrieves the exclusion range for a specified multicast scope.
Get-DhcpServerv4MulticastLease: Retrieves multicast leases for a specified scope name.
Get-DhcpServerv4MulticastScope: Gets multicast scope objects.
Get-DhcpServerv4MulticastScopeStatistics: Gets multicast scope statistics.
Get-DhcpServerv4SuperscopeStatistics: Returns statistics for superscopes.
Remove-DhcpServerDnsCredential: Removes the credential that the DHCP Server service uses to register or deregister client records on a DNS server.
Remove-DhcpServerv4MulticastExclusionRange: Removes a range of addresses previously excluded from a multicast scope.
Remove-DhcpServerv4MulticastLease: Removes one or more multicast scope leases for a specified multicast scope or IP address.
Remove-DhcpServerv4MulticastScope: Removes multicast scopes.
Rename-DhcpServerv4Superscope: Renames a superscope.
Repair-DhcpServerv4IPRecord: Reconciles inconsistent lease records in the DHCP database.
Set-DhcpServerDnsCredential: Sets credentials that the DHCP Server service uses to register or deregister client records on a DNS server.
Set-DhcpServerv4MulticastScope: Modifies the properties of a multicast scope.


There are many things which you can achieve using this cmdlets

@@@@ Get list of all DHCP scopes on a DHCP server

Get-DhcpServerv4Scope -ComputerName Server1 | fl
Get-DhcpServerv4Scope -ComputerName Server1,Server2 | Select-Object Scopeid,Name,State,StartRanage, EndRange
# Will give you specific details on DHCP scope details from remote server named Server1 and Server2

@@@@ Adding new scope using ADD-DhcpServerv4Scope
Add-DHCPServerv4Scope -Name Test_Scope -StartRange 192.168.100.50 -EndRange 192.168.100.100 -SubnetMask 255.255.255.0

@@@@ Count DHCP Server in environment
(Get-Command -Module DHCPServer).count

@@@@ To authorize a new DHCP server in Active Directory Domain
Add-DhcpServerInDC -DnsName Script.Chef.com -IPAddress 10.9.0.78

@@@@ Configuring multiple scope in DHCP server

$Scopes = Get-Content -Path C:\Scopes.csv    #Reading Scopes from txt file

$DnsServer=10.9.0.7,10.990.8,10.9.0.0
$Domain=Shanky.chef.com
$Router=10.9.0.1

Foreach($Scope in $Scopes)
{
Set-DHCPServerv4OptionValue -ComputerName DhcpSrv1 -ScopeId $Scope -DnsServer $DnsServer -DnsDomain $Domain -Router $Router
}


@@@@ Create a reservation for a client with the IP-address 10.44.1.88:

Get-DhcpServerv4Lease -ComputerName DhcpSvr1 -IPAddress 10.44.1.88 | Add-DhcpServerv4Reservation -ComputerName DhcpSvr1

You can perform a mass reservation of IP-addresses for computers listed in a CSV file. To do it, create a text file in the following format:

ScopeId,IPAddress,Name,ClientId,Description

10.44.1.0,10.44.1.88,Client1,b3-ac-5c-fd-9e-6f,Reservation DhcpSvr1

10.44.1.0,10.44.1.89,Client2,b3-ac-5c-fd-9e-3f,Reservation DhcpSvr1

Save this file as c:\dhcp\DHCP_Reservations.csv and run the next command that imports the data from the CSV file and creates reservations for the clients:

Import-Csv –Path c:\dhcp\DHCP_Reservations.csv | Add-DhcpServerv4Reservation -ComputerName DhcpSvr2


@@@@ You can get DHCP server statistics (the number of scopes and reservations, the percentage of used addresses, etc.).

Get-DhcpServerv4Statistics -ComputerName DhcpSvr1

Wednesday, June 8, 2016

DNS Scripts - Powershell


This script just gets and displays host details returned by GetHostByName.

     $hostInfo = [system.net.Dns]::GetHostByName("www.google.com");
     $hostinfo | fl * -force














This script just gets IP address of remote computer

Demonstrates use of the GetHostIP method of System.Net.DNS Class

param (
[string] $HostName = "localhost"
)

###
# Start of Script
###

#Get Host details

$hostentrydetails = [System.Net.Dns]::GetHostEntry($hostname)

# Print details:
"Host Name    : {0}" -f $hostentrydetails.HostName
foreach ($alias in $hostentrydetails.alises) {
"Alias        : {0}" -f $alias
}
foreach ($addr in $hostentrydetails.addresslist) {
"Address      : {0}" -f $Addr.ipaddresstostring
}







There is another way to get DNS host Entries,

###
# Start of Script
###

# Convert $hostaddres to IPaddress class. 

# Create one for next call
$HostIp = [System.Net.IPAddress]::Parse("127.0.0.1")
if (! ([system.Net.IPAddress]::TryParse($hostaddress, [ref] $HostIP))) {"Not valid IP address"; return}

# Get Host info
$hostentrydetails = [System.Net.Dns]::GetHostEntry($HostIP)

# Print details:
"Host Name    : {0}" -f $hostentrydetails.HostName
foreach ($alias in $hostentrydetails.alises) {
"Alias        : {0}" -f $alias
}
foreach ($addr in $hostentrydetails.addresslist) {
"Address      : {0}" -f $Addr.ipaddresstostring
}

# End of script


Get System Environment value of remote computer - Powershell Script


<#
.SYNOPSIS
    This script demonstrates the use of System.Environment
.DESCRIPTION
    This script Uses a variety of the members of System.Environment and is
    a re-write of a MSDN Sample Script
.EXAMPLE
    PSH [C:\foo]: .\Get-System.Environment.ps1' foo1 foo2 foo3
    My system drive is C: and my system root is C:\Windows

.PARAMETER
    None, but if any are provided, they are displayed above
#>

##
# Start of Script
##

# Setup two variables for later use
[String] $str;
[string] $nl = [System.Environment]::NewLine

# Now display members of the environment class
"-- Environment members --"
#  Assume: You Invoke this sample with an arbitrary set of command line arguments.
"CommandLine       : {0}"   -f [system.environment]::CommandLine
$arguments = [System.Environment]::GetCommandLineArgs()
"GetCommandLineArgs: {0}"   -f [system.string]::join(", ", $arguments)
#  <-- Keep this information secure! -->
"CurrentDirectory  : {0}"   -f [System.Environment]::CurrentDirectory
"ExitCode          : {0}"   -f [System.Environment]::ExitCode
"HasShutdownStarted: {0}"   -f [System.Environment]::HasShutdownStarted
#  <-- Keep this information secure! -->
"MachineName       : {0}"   -f [System.Environment]::MachineName
"NewLine           : {0}  first line{0}  second line{0}  third line" -f [System.Environment]::NewLine
"OSVersion         : {0}"   -f [System.Environment]::OSVersion.ToString()
"StackTrace        : '{0}'" -f [System.Environment]::StackTrace
#  <-- Keep this information secure! -->
"SystemDirectory   : {0}"    -f [System.Environment]::SystemDirectory
"TickCount         : {0}"    -f [System.Environment]::TickCount
#  <-- Keep this information secure! -->
"UserDomainName    : {0}"    -f [System.Environment]::UserDomainName
"UserInteractive   : {0}"    -f [System.Environment]::UserInteractive
#  <-- Keep this information secure! -->
"UserName          : {0}"    -f [System.Environment]::UserName
"Version           : {0}"    -f [System.Environment]::Version.ToString()
"WorkingSet        : {0}"    -f [System.Environment]::WorkingSet
#  No example for exit(exitCode) because doing so would terminate this example.
#  <-- Keep this information secure! -->
$query = "My system drive is %SystemDrive% and my system root is %SystemRoot%";
$str = [System.Environment]::ExpandEnvironmentVariables($query)
"ExpandEnvironmentVariables: {0}  {1}" -f $nl,$str
"GetEnvironmentVariable: {0}  My temporary directory is {1}." -f $nl,[System.Environment]::GetEnvironmentVariable("TEMP")
""
"GetEnvironmentVariables: "
[System.Environment]::GetEnvironmentVariables()
"GetFolderPath: {0}" -f [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::System)
[String[]] $drives = [System.Environment]::GetLogicalDrives()
"GetLogicalDrives: {0}" -f [System.String]::Join(", ", $drives)
#End of Script

Reference - MSDN Gallery

Fix File Name - Powershell Script


<#
.SYNOPSIS
    Defines a function to remove 'invalid' characters
    from a file name
.DESCRIPTION
    Some programs do not like certain 'invalid' characters
    in a file name used by that application. The function
    takes a look at each the file name and replaces some invalid
    characters with '-'.

    This function takes a file name and 'fixes' it and returns
    the 'fixed' file name. Needless to say the characters to match
    and what to replace them with is an application specific decision!
.NOTES
    Requires   : PowerShell Version 3.0
.EXAMPLE
    Psh> .\Fix-FileName.ps1
    File name was: 123{}{{{|[\]
    Fixed name is: 123--------
#>


Function Fix-FileName {
[CMdletbinding()]
Param (
$fn = $(throw 'no file name specified - returning')
)

Switch -Regex ($fn) {
  "}"  { $fn = $fn -replace '{','-'  }
  "}"  { $fn = $fn -replace '}','-'  }
  "\]" { $fn = $fn -replace ']','-'  }
  "\[" { $fn = $fn -replace '\[','-' }
  "\\" { $fn = $fn -replace '\\','-' }
  "\|" { $fn = $fn -replace '\|','-' }
}
$fn
}

$fn = "123{}{{{|[\]"
$fnf = Fix-FileName $fn
"File name was: $fn"
"Fixed name is: $fnf"


Reference - pshscripts.blogspot.com

Sunday, June 5, 2016

PS command for AD user management - one liners

1#How to check Powershell Version?
$host.Version.Major
OR
$psversiontable
OR
:::::::::Microsoft Powershell:::::::
Get-Host | Select-Object Version

2#How to find Users from an OU using ADSI?
$test =
[adsi] "LDAP://localhost:389/ou=test,dc=contoso,dc=COM"
$searcher = [adsisearcher] $test
$searcher.Filter = '(objectClass=User)'
$searcher.FindAll()
3#All AD Users All attrs.
Get-ADUser -F * -PR * | Export-Csv Usersreports.csv -NoTypeInformation

4#How to find Locked out accounts?
search-adaccount -u -l | ft name,lastlogondate -auto

4A#To unlock an account
Unlock-ADAccount -Identity Shanky

5#Finding the Lockout Events
#Windows 2008
Get-EventLog -log Security | ? EventID -EQ 4740
#Windows 2003
Get-EventLog -log Security | ? EventID -EQ 644

6#Find some specific attributes for an OU users
get-aduser -f * -Searchbase "ou=powershell,dc=contoso,dc=com" -pr SamAccountName,PasswordExpired,whenChanged,UserPrincipalName

7#Find some specific attributes using input file
get-content c:\users.txt | get-aduser -pr SamAccountName,PasswordExpired,whenChanged,UserPrincipalName

8#How to reset the passwords for some specific users
get-content c:\users.txt | get-aduser | Set-ADAccountPassword -NewPassword (ConvertTo-SecureString -AsPlainText monster@me123 -Force)

9#How to update the manager field for bulk users?
get-content c:\users.txt | get-aduser | Set-ADUser -Manager "shanky"

10#How to update "ProfilePath","homeDrive" & "HomeDirectory" based on a input file?
Get-Content users.txt | ForEach-Object {
  Set-ADUser -Identity $_ -ProfilePath "\\WIN-85IOGS94Q68\profile\$_" -homedrive "Y:" -homedirectory "\\WIN-85IOGS94Q68\netshare\$_"
}

11#Find Users exist in AD or Not?
$users = get-content c:\users.txt
foreach ($user in $users) {
$User = Get-ADUser -Filter {(samaccountname -eq $user)}
If ($user -eq $Null) {"User does not exist in AD ($user)" }
Else {"User found in AD ($user)"}
}

12#Find users are enabled and have E-Mail and Homedirectory and PasswordExpired -eq false)}
PS C:\> Get-ADUser -Filter {(enabled -eq $true) -and (EmailAddress -like "*") -and (Homedirectory -like "*") -and (PasswordExpired -eq $false)}

13#Also finding the Groupmembership.
PS C:\>  Get-ADUser -Filter {(enabled -eq $true) -and (EmailAddress -like "*") -and (Homedirectory -like "*") -and
(PasswordExpired -eq $false) -and (MemberOf -eq "CN=rock2,OU=win7,DC=Jaihanuman,DC=net")}

14#ProtectedFromAccidentalDeletion for all the users
Get-ADObject -filter {(ObjectClass -eq "user")} | Set-ADObject -ProtectedFromAccidentalDeletion:$true

15# How to find the users property using ADSI.
$users1=[ADSI]"LDAP://cn=copy,cn=users,dc=contoso,dc=com"
$users1 | select *

16#search-adaccount (Accounts Disable,inactive)
search-adaccount (Accounts Disable,inactive)
search-adaccount -u -accountd -searchb "ou=test,dc=contoso,dc=com"
search-adaccount -u -accountd
search-adaccount -u -accounti -t "90"
search-adaccount -u -accounti -da "28 feb 2013"

17# Enable Bulk AD user accounts based on a  input file
Cat c:\users.txt | get-aduser | Enable-ADAccount

18# Disabled Bulk AD user accounts based on a  input file
Cat c:\users.txt | get-aduser | Disable-ADAccount


::::::::Quest Powershell:::::::::
1#Find the Disabled members from multiple GROUPS.
Get-Content c:\groups.txt | ForEach-Object {
  Get-QADGroupMember $_ -Disabled
}
2#Find the E-MAILs of Users form an particular OU
get-QADuser -SearchRoot 'contoso.com/test' | select samaccountname,mail



Reference - Miscrosoft Technet

Windows Server 2016 Key Features and License Prospects

If you are planning to move to Windows 2016 and looking for benefits, I have listed down below : Why Windows Server 2016? ·     ...