This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://www.lazywinadmin.com/2013/10/powershell-get-domainuser.html | |
function Get-DomainUser { | |
PARAM($DisplayName) | |
$Search = [adsisearcher]"(&(objectCategory=person)(objectClass=User)(displayname=$DisplayName))" | |
foreach ($user in $($Search.FindAll())){ | |
New-Object -TypeName PSObject -Property @{ | |
"DisplayName" = $user.properties.displayname -as [string] | |
"UserName" = $user.properties.samaccountname -as [string] | |
"Description" = $user.properties.description -as [string] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://www.lazywinadmin.com/2013/10/powershell-get-domainuser.html | |
function Get-DomainUser { | |
PARAM($DisplayName) | |
$Search = [adsisearcher]"(&(objectCategory=person)(objectClass=User)(displayname=$DisplayName))" | |
foreach ($user in $($Search.FindAll())){ | |
New-Object -TypeName PSObject -Property @{ | |
"DisplayName" = $user.properties.displayname -as [string] | |
"UserName" = $user.properties.samaccountname -as [string] | |
"Description" = $user.properties.description -as [string] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-DomainUser | |
{ | |
PARAM ($DisplayName,[Adsi]$SearchRoot= "LDAP://OU=Servers,OU=TEST,dc=fx,dc=lab") | |
$Search = [adsisearcher]"(&(objectCategory=person)(objectClass=User)(displayname=$DisplayName))" | |
$Search.searchRoot = $SearchRoot | |
foreach ($user in $($Search.FindAll())) | |
{ | |
New-Object -TypeName PSObject -Property @{ | |
"DisplayName" = $user.properties.displayname -as [string] | |
"UserName" = $user.properties.samaccountname -as [string] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-NestedMember | |
{ | |
<# | |
.SYNOPSIS | |
Find all Nested members of a group | |
.DESCRIPTION | |
Find all Nested members of a group | |
.PARAMETER GroupName | |
Specify one or more GroupName to audit | |
.Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-VMHost | Where-Object { $_.ConnectionState -eq “Connected” } | Foreach-Object { | |
$CurrentVMhost = $_ | |
TRY | |
{ | |
# Exposes the ESX CLI functionality of the current host | |
$ESXCLI = Get-EsxCli -VMHost $CurrentVMhost.name | |
# Retrieve Vib with name 'net-e1000e' | |
$ESXCLI.software.vib.list() | Where-object { $_.Name -eq "net-e1000e" } | | |
FOREACH | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Source: Reddit (http://www.reddit.com/r/PowerShell/comments/2oqk4k/using_validateset_with_exceptions/) | |
function test { | |
# You have to use cmdletbinding for the dynamic parameter to work | |
[CmdletBinding()] | |
Param() | |
# The cool thing about this is that you can actually get really good tab completion / intellisense from doing it this way... | |
DynamicParam | |
{ | |
[string[]]$ValidServices = get-content $PSScriptRoot\services.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-Uptime | |
{ | |
$millisec = [Environment]::TickCount | |
[Timespan]::FromMilliseconds($millisec) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ForEach-Parallel | |
{ | |
<# | |
.DESCRIPTION | |
.SYNOPSIS | |
.NOTES | |
Source: http://powertoe.wordpress.com/2012/05/03/foreach-parallel/ | |
.EXAMPLE | |
(0..50) |ForEach-Parallel -MaxThreads 4{ | |
$_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"::1" -as [ipaddress] | fl * -Force | |
IPAddressToString : ::1 | |
Address : | |
AddressFamily : InterNetworkV6 | |
ScopeId : 0 | |
IsIPv6Multicast : False | |
IsIPv6LinkLocal : False | |
IsIPv6SiteLocal : False | |
IsIPv6Teredo : False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Jeff Hicks | |
# http://www.petri.com/creating-advance-functions-powershell.htm?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Petri+%28Petri+IT+Knowledgebase%29 | |
Function Get-MyUptime { | |
[cmdletbinding()] | |
Param( | |
[Parameter(Position=0,ValueFromPipeline,ValueFromPipelineByPropertyName)] | |
[ValidateNotNullorEmpty()] | |
[Alias("cn","host")] | |
[string[]]$Computername = $env:Computername |
OlderNewer