Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AD-COMPUTER-Get-DomainComputer/Get-DomainComputer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.DESCRIPTION
The Get-DomainComputer function allows you to get information from an Active Directory Computer object using ADSI.
You can specify: how many result you want to see, which credentials to use and/or which domain to query.
You can specify: how many results you want to see, which credentials to use and/or which domain to query.

.PARAMETER ComputerName
Specifies the name(s) of the Computer(s) to query
Expand Down Expand Up @@ -47,7 +47,7 @@
Get-DomainComputer -ComputerName "Workstation0*" -SizeLimit 10 -Verbose

This will query information for computers starting with 'Workstation0', but only show 10 results max.
The Verbose parameter allow you to track the progression of the script.
The Verbose parameter allows you to track the progression of the script.

.EXAMPLE
Get-DomainComputer -ComputerName "Workstation0*" -SizeLimit 10 -Verbose -DomainDN "DC=FX,DC=LAB" -Credential (Get-Credential -Credential FX\Administrator)
Expand Down
2 changes: 1 addition & 1 deletion AD-FSMO-Get-ADFSMORole/AD-FSMO-Get-ADFSMORole.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Get-ADFSMORole {
@lazywinadmin
github.com/lazywinadmin

1.0 | 2016/00/00 | Francois-Xavier Cat
1.0 | 2016/01/01 | Francois-Xavier Cat
Initial Version
1.1 | 2017/11/01 | Francois-Xavier Cat
Update Error handling
Expand Down
4 changes: 2 additions & 2 deletions AD-GPO-Get-ADGPOReplication/AD-GPO-Get-ADGPOReplication.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function Get-ADGPOReplication {
<#
.SYNOPSIS
This function retrieve one or all the GPO and report their DSVersions and SysVolVersions (Users and Computers)
This function retrieves one or all GPOs and report their DSVersions and SysVolVersions (Users and Computers)
.DESCRIPTION
This function retrieve one or all the GPO and report their DSVersions and SysVolVersions (Users and Computers)
This function retrieves one or all GPOs and report their DSVersions and SysVolVersions (Users and Computers)
.PARAMETER GPOName
Specify the name of the GPO
.PARAMETER All
Expand Down
2 changes: 1 addition & 1 deletion AD-GPO-Get-ADGPOReplication/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Get-ADGPOReplication

[Blog article on lazywinadmin.com](http://www.lazywinadmin.com/2014/10/powershell-check-gpo-replication.html)

Get-ADGPOReplication is retrieving the GPO version and Sysvol version accross the domain for one or more Group Policy objects. This can especially helps you troubleshooting replication issues.
Get-ADGPOReplication is retrieving the GPO version and Sysvol version across the domain for one or more Group Policy objects. This can especially helps you troubleshooting replication issues.

This small function is taking advantage of the module ActiveDirectory to retrieve the list of all Domain Controllers and the module GroupPolicy to query one or more Group Policy objects.

Expand Down
10 changes: 4 additions & 6 deletions AD-GROUP-Get-NestedMember/AD-GROUP-Get-NestedMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function Get-NestedMember {
PARAM(
[String[]]$GroupName,
[String]$RelationShipPath,
[Int]$MaxDepth
[Int]$MaxDepth,
[Int]$DepthCount = 1
)
TRY {
$FunctionName = (Get-Variable -Name MyInvocation -Scope 0 -ValueOnly).MyCommand
Expand All @@ -41,8 +42,6 @@ function Get-NestedMember {
Import-Module -Name ActiveDirectory -ErrorAction Stop
}

# Set Depth Counter
$DepthCount = 1
FOREACH ($Group in $GroupName) {
Write-Verbose -Message "[$FunctionName] Group '$Group'"

Expand Down Expand Up @@ -75,10 +74,9 @@ function Get-NestedMember {
# Output Object
$CurrentObject | Select-Object Name, SamAccountName, ObjectClass, DistinguishedName, @{Label = "ParentGroup"; Expression = { $ParentGroup } }, @{Label = "RelationShipPath"; Expression = { $RelationShipPath } }

if (-not($DepthCount -lt $MaxDepth)) {
if (-not $MaxDepth -or $DepthCount -lt $MaxDepth) {
# Find Child
Get-NestedMember -GroupName $CurrentObject.Name -RelationShipPath $RelationShipPath
$DepthCount++
Get-NestedMember -GroupName $CurrentObject.Name -RelationShipPath $RelationShipPath -MaxDepth $MaxDepth -DepthCount ($DepthCount + 1)
}
}#Group
default { $CurrentObject | Select-Object Name, SamAccountName, ObjectClass, DistinguishedName, @{Label = "ParentGroup"; Expression = { $ParentGroup } }, @{Label = "RelationShipPath"; Expression = { $RelationShipPath } } }
Expand Down
22 changes: 11 additions & 11 deletions AD-GROUP-Get-ParentGroup/AD-GROUP-Get-ParentGroup.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
function Get-ParentGroup {
<#
.SYNOPSIS
Find all Nested members of a group
Find all parent groups of an AD object
.DESCRIPTION
Find all Nested members of a group
Find all parent groups of an AD object by walking the memberof attribute
.PARAMETER Name
Specify one or more GroupName to audit
Specify one or more object names (ANR or distinguishedName) to look up parent groups for
.Example
Get-NestedMember -GroupName TESTGROUP
Get-ParentGroup -Name TESTUSER

This will find all the indirect members of TESTGROUP
This will find all parent groups of TESTUSER
.Example
Get-NestedMember -GroupName TESTGROUP,TESTGROUP2
Get-ParentGroup -Name TESTGROUP,TESTUSER

This will find all the indirect members of TESTGROUP and TESTGROUP2
This will find all parent groups of TESTGROUP and TESTUSER
.Example
Get-NestedMember TESTGROUP | Group Name | select name, count
Get-ParentGroup TESTUSER | Group Name | select name, count

This will find duplicate
This will find duplicate parent group entries
.link
https://github.com/lazywinadmin/PowerShell

Expand Down Expand Up @@ -57,7 +57,7 @@ function Get-ParentGroup {
Write-Output $CurrentObject | Select-Object Name, SamAccountName, ObjectClass, @{L = "Child"; E = { $Account.samaccountname } }

Write-Verbose -Message "Inception - $($CurrentObject.distinguishedname)"
Get-ParentGroup -OutBuffer $CurrentObject.distinguishedname
Get-ParentGroup -Name $CurrentObject.DistinguishedName

}#$Account | Select-Object
}#FOREACH ($Account in $ADObject){
Expand All @@ -72,6 +72,6 @@ function Get-ParentGroup {
}
}#PROCESS
END {
Write-Verbose -Message "[END] Get-NestedMember"
Write-Verbose -Message "[END] Get-ParentGroup"
}
}
23 changes: 14 additions & 9 deletions AD-OBJECT-Get-ADSITokenGroup/Get-ADSITokenGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,26 @@ function Get-ADSITokenGroup {
# Building the basic search object with some parameters
$Search = New-Object -TypeName System.DirectoryServices.DirectorySearcher -ErrorAction 'Stop'
$Search.SizeLimit = $SizeLimit
$Search.SearchRoot = $DomainDN
#$Search.Filter = "(&(anr=$SamAccountName))"
$Search.Filter = "(&((objectclass=user)(samaccountname=$SamAccountName)))"

# Credential
# Normalize Domain DN only when the caller passed DomainDistinguishedName
$SearchRootPath = $null
IF ($PSBoundParameters['DomainDistinguishedName']) {
$SearchRootPath = $DomainDistinguishedName
IF ($SearchRootPath -notlike "LDAP://*") { $SearchRootPath = "LDAP://$SearchRootPath" }#IF
Write-Verbose -Message "[PROCESS] Different Domain specified: $SearchRootPath"
}

# Credential (bind DirectoryEntry after LDAP path is normalized if Domain was also passed)
IF ($PSBoundParameters['Credential']) {
$Cred = New-Object -TypeName System.DirectoryServices.DirectoryEntry -ArgumentList $DomainDistinguishedName, $($Credential.UserName), $($Credential.GetNetworkCredential().password)
IF ($SearchRootPath) { $BindPath = $SearchRootPath }
ELSE { $BindPath = $DomainDistinguishedName }
$Cred = New-Object -TypeName System.DirectoryServices.DirectoryEntry -ArgumentList $BindPath, $($Credential.UserName), $($Credential.GetNetworkCredential().password)
$Search.SearchRoot = $Cred
}

# Different Domain
IF ($DomainDistinguishedName) {
IF ($DomainDistinguishedName -notlike "LDAP://*") { $DomainDistinguishedName = "LDAP://$DomainDistinguishedName" }#IF
Write-Verbose -Message "[PROCESS] Different Domain specified: $DomainDistinguishedName"
$Search.SearchRoot = $DomainDistinguishedName
ELSEIF ($SearchRootPath) {
$Search.SearchRoot = $SearchRootPath
}

$Search.FindAll() | ForEach-Object -Process {
Expand Down
4 changes: 2 additions & 2 deletions AD-SITE-Add-ADSubnet(ADSI)/Add-ADSubnet.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Function Add-ADSubnet {
<#
.SYNOPSIS
This function allow you to add a subnet object in your active directory using ADSI
This function allows you to add a subnet object in your active directory using ADSI

.DESCRIPTION
This function allow you to add a subnet object in your active directory using ADSI
This function allows you to add a subnet object in your active directory using ADSI

.PARAMETER Subnet
Specifies the Name of the subnet to add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
FIX issue with sending the email
1.5.0 2015.03.12
ADD Search all domains in the forest
ADD NETLOGON file version detection (from 2012, NETLOGON contains a colomn for ErrorCode)
ADD NETLOGON file version detection (from 2012, NETLOGON contains a column for ErrorCode)
ADD some Verbose/Warning message
ADD Support for SMTP Port (Parameter EmailSMTPPort), default is 25
UPDATE Logic of the script (now append csv for each DC, and process the CSV files and Build html at the end of the PROCESS block)
Expand Down
4 changes: 2 additions & 2 deletions AD-SITE-Get-ADSIComputerSite/Get-ADSIComputerSite.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ function Get-ADSIComputerSite {
Specifies the computer name(s) that you want to know the site.

.EXAMPLE
Get-ADSIComputerName -ComputerName TestServer01
Get-ADSIComputerSite -ComputerName TestServer01

This will retrieve the Site of the Computer TestServer01

.EXAMPLE
Get-ADSIComputerName -ComputerName TestServer01,TestServer02
Get-ADSIComputerSite -ComputerName TestServer01,TestServer02

This will retrieve the Site of the Computers TestServer01 and TestServer02

Expand Down
2 changes: 1 addition & 1 deletion AD-SITE-Get-ADSiteInventory/Get-ADSiteInventory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function Get-ADSiteInventory {
DataCompressionEnabled = $LinksInfo.DataCompressionEnabled -join ','
#}
#>
}#New-Object -TypeName PSoBject
}#New-Object -TypeName PSObject
}#Foreach ($item in $SiteInfo)
}#TRY
CATCH {
Expand Down
8 changes: 4 additions & 4 deletions AD-USER-Get-ADDirectReport/Get-ADDirectReport.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
function Get-ADDirectReports {
<#
.SYNOPSIS
This function retrieve the directreports property from the IdentitySpecified.
This function retrieves the directreports property from the IdentitySpecified.
Optionally you can specify the Recurse parameter to find all the indirect
users reporting to the specify account (Identity).
users reporting to the specified account (Identity).

.DESCRIPTION
This function retrieve the directreports property from the IdentitySpecified.
This function retrieves the directreports property from the IdentitySpecified.
Optionally you can specify the Recurse parameter to find all the indirect
users reporting to the specify account (Identity).
users reporting to the specified account (Identity).

.NOTES
Francois-Xavier Cat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Function Get-AccountLockedOut {
.PARAMETER DomainName
Specifies the DomainName to query, by default it takes the current domain ($env:USERDOMAIN)
.PARAMETER UserName
Specifies the DomainName to query, by default it takes the current domain ($env:USERDOMAIN)
Specifies the sAMAccountName to search. Wildcards allowed. Default '*'.
.EXAMPLE
Get-AccountLockedOut -UserName * -StartTime (Get-Date).AddDays(-5) -Credential (Get-Credential)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ BEGIN {
$SMTPMessage.BodyEncoding = $Encoding
$SMTPMessage.SubjectEncoding = $Encoding

# Attachement Parameter
# Attachment Parameter
IF ($PSBoundParameters['attachment']) {
$SMTPattachment = New-Object -TypeName System.Net.Mail.Attachment -ArgumentList $attachment
$SMTPMessage.Attachments.Add($SMTPattachment)
Expand All @@ -158,7 +158,7 @@ BEGIN {
$SMTPClient.EnableSsl = $true
}

# Credential Paramenter
# Credential Parameter
#IF (($PSBoundParameters['Username']) -and ($PSBoundParameters['Password'])) {
IF ($PSBoundParameters['Credential']) {
# Create Credential Object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Script to update or overwrite App Service IP Rules Restriction based on a CSV fi
.DESCRIPTION
Script to update or overwrite App Service IP Rules Restriction based on a CSV file provided

The script only validate the IPAddress property to defined if an IP Rule is already present.
The script only validates the IPAddress property to determine if an IP Rule is already present.
It does not check the other properties such as Priority, Name, Description, ...

The script will output the IPRules present on the App Service in the output.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ function Get-AzureIPRangesAndServiceTags {
<#
.SYNOPSIS

Retrieve the Ip address ranges and Service Tags ranges for Azure (Public, USgov, Germnay or China)
The function return a Json. This can be passed to '|Converfrom-json' if you wish
Retrieve the Ip address ranges and Service Tags ranges for Azure (Public, USgov, Germany or China)
The function return a Json. This can be passed to '| ConvertFrom-Json' if you wish
to get a PowerShell object.

This information is pulled from Microsoft Download pages.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function Invoke-ComplianceEvaluation {
<#
.SYNOPSIS
Function to trigger compliance evalution for Azure Policies on a specific Resource Group or Subscription
Function to trigger compliance evaluation for Azure Policies on a specific Resource Group or Subscription
.description
The code assume you are already authenticated to azure
.example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function Connect-ExchangeOnPremises {
.LINK
https://github.com/lazywinadmin/PowerShell
#>
[CmdletBinding()]
PARAM (
[Parameter(Mandatory, HelpMessage = 'http://<ServerFQDN>/powershell')]
[system.string]$ConnectionUri,
Expand Down
1 change: 1 addition & 0 deletions EXCHANGE-Connect-ExchangeOnline/Connect-ExchangeOnline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function Connect-ExchangeOnline {
https://github.com/lazywinadmin/PowerShell
#>

[CmdletBinding()]
param
(
[system.string]$ConnectionUri = 'https://ps.outlook.com/powershell/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function Get-SCCMClientCacheInformation {
Specifies the name of the client
.PARAMETER Credential
Specifies the credential to use against the remote machine
Only work with the WMI query for now, not the service restart
.EXAMPLE
Get-SCCMClientCacheInformation -ComputerName Client01

Expand Down Expand Up @@ -58,7 +57,7 @@ function Get-SCCMClientCacheInformation {
}
CATCH {
Write-Warning -message "[PROCESS] Something Wrong happened with $Computer"
$Error[0].execption.message
$Error[0].Exception.Message
}
}
}
11 changes: 7 additions & 4 deletions SCCM-Set-SCCMClientCacheLocation/Set-SCCMClientCacheLocation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ function Set-SCCMClientCacheLocation {
.LINK
https://github.com/lazywinadmin/PowerShell
#>
[CmdletBinding(SupportsShouldProcess)]
PARAM(
[string[]]$ComputerName = ".",

[parameter(Mandatory)]
[int]$Location,
[string]$Location,

[Switch]$ServiceRestart,

Expand Down Expand Up @@ -59,10 +60,12 @@ function Set-SCCMClientCacheLocation {
}

TRY {
# Set the Cache Size
# Set the Cache Location
$Cache = Get-WmiObject @SplattingWMI
$Cache.location = $Location
$Cache.Put()
IF ($PSCmdlet.ShouldProcess($Computer, "Set SCCM client cache location to $Location")) {
$Cache.location = $Location
$Cache.Put()
}

# Restart SCCM Client
IF ($PSBoundParameters['ServiceRestart']) {
Expand Down
2 changes: 1 addition & 1 deletion SCCM-Set-SCCMClientCacheSize/Set-SCCMClientCacheSize.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function Set-SCCMClientCacheSize {
}
CATCH {
Write-Warning -message "[PROCESS] Something Wrong happened with $Computer"
$Error[0].execption.message
$Error[0].Exception.Message
}
}
}
2 changes: 1 addition & 1 deletion TOOL-Clean-MacAddress/Clean-MacAddress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function Clean-MacAddress {
# Initial Cleanup
$MacAddress = $MacAddress -replace "-", "" #Replace Dash
$MacAddress = $MacAddress -replace ":", "" #Replace Colon
$MacAddress = $MacAddress -replace "/s", "" #Remove whitespace
$MacAddress = $MacAddress -replace "\s", "" #Remove whitespace
$MacAddress = $MacAddress -replace " ", "" #Remove whitespace
$MacAddress = $MacAddress -replace "\.", "" #Remove dots
$MacAddress = $MacAddress.trim() #Remove space at the beginning
Expand Down
2 changes: 1 addition & 1 deletion TOOL-Disable-RemoteDesktop/Disable-RemoteDesktop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function Disable-RemoteDesktop {
CATCH {
Write-Warning -Message (Get-DefaultMessage -Message "$Computer - Something wrong happened")
IF ($ErrorProcessGetWmi) { Write-Warning -Message (Get-DefaultMessage -Message "$Computer - Issue with Get-WmiObject") }
Write-Warning -MEssage $Error[0].Exception.Message
Write-Warning -Message $Error[0].Exception.Message
}
FINALLY {
$Splatting.Clear()
Expand Down
2 changes: 1 addition & 1 deletion TOOL-Enable-RemoteDesktop/Enable-RemoteDesktop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function Enable-RemoteDesktop {
CATCH {
Write-Warning -Message (Get-DefaultMessage -Message "$Computer - Something wrong happened")
IF ($ErrorProcessGetWmi) { Write-Warning -Message (Get-DefaultMessage -Message "$Computer - Issue with Get-WmiObject") }
Write-Warning -MEssage $Error[0].Exception.Message
Write-Warning -Message $Error[0].Exception.Message
} #CATCH
FINALLY {
$Splatting.Clear()
Expand Down
Loading