diff --git a/AD-COMPUTER-Get-DomainComputer/Get-DomainComputer.ps1 b/AD-COMPUTER-Get-DomainComputer/Get-DomainComputer.ps1 index aa63e156..40ce5c7f 100644 --- a/AD-COMPUTER-Get-DomainComputer/Get-DomainComputer.ps1 +++ b/AD-COMPUTER-Get-DomainComputer/Get-DomainComputer.ps1 @@ -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 @@ -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) diff --git a/AD-FSMO-Get-ADFSMORole/AD-FSMO-Get-ADFSMORole.ps1 b/AD-FSMO-Get-ADFSMORole/AD-FSMO-Get-ADFSMORole.ps1 index fecc7d64..c6ec61e1 100644 --- a/AD-FSMO-Get-ADFSMORole/AD-FSMO-Get-ADFSMORole.ps1 +++ b/AD-FSMO-Get-ADFSMORole/AD-FSMO-Get-ADFSMORole.ps1 @@ -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 diff --git a/AD-GPO-Get-ADGPOReplication/AD-GPO-Get-ADGPOReplication.ps1 b/AD-GPO-Get-ADGPOReplication/AD-GPO-Get-ADGPOReplication.ps1 index 981783b4..f3d7aceb 100644 --- a/AD-GPO-Get-ADGPOReplication/AD-GPO-Get-ADGPOReplication.ps1 +++ b/AD-GPO-Get-ADGPOReplication/AD-GPO-Get-ADGPOReplication.ps1 @@ -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 diff --git a/AD-GPO-Get-ADGPOReplication/README.MD b/AD-GPO-Get-ADGPOReplication/README.MD index 41ce8338..bea3e5f3 100644 --- a/AD-GPO-Get-ADGPOReplication/README.MD +++ b/AD-GPO-Get-ADGPOReplication/README.MD @@ -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. diff --git a/AD-GROUP-Get-NestedMember/AD-GROUP-Get-NestedMember.ps1 b/AD-GROUP-Get-NestedMember/AD-GROUP-Get-NestedMember.ps1 index ae12bc51..ef97e69d 100644 --- a/AD-GROUP-Get-NestedMember/AD-GROUP-Get-NestedMember.ps1 +++ b/AD-GROUP-Get-NestedMember/AD-GROUP-Get-NestedMember.ps1 @@ -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 @@ -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'" @@ -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 } } } diff --git a/AD-GROUP-Get-ParentGroup/AD-GROUP-Get-ParentGroup.ps1 b/AD-GROUP-Get-ParentGroup/AD-GROUP-Get-ParentGroup.ps1 index 6a180046..47ce0219 100644 --- a/AD-GROUP-Get-ParentGroup/AD-GROUP-Get-ParentGroup.ps1 +++ b/AD-GROUP-Get-ParentGroup/AD-GROUP-Get-ParentGroup.ps1 @@ -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 @@ -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){ @@ -72,6 +72,6 @@ function Get-ParentGroup { } }#PROCESS END { - Write-Verbose -Message "[END] Get-NestedMember" + Write-Verbose -Message "[END] Get-ParentGroup" } } \ No newline at end of file diff --git a/AD-OBJECT-Get-ADSITokenGroup/Get-ADSITokenGroup.ps1 b/AD-OBJECT-Get-ADSITokenGroup/Get-ADSITokenGroup.ps1 index 32a98e88..bc46a5c7 100644 --- a/AD-OBJECT-Get-ADSITokenGroup/Get-ADSITokenGroup.ps1 +++ b/AD-OBJECT-Get-ADSITokenGroup/Get-ADSITokenGroup.ps1 @@ -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 { diff --git a/AD-SITE-Add-ADSubnet(ADSI)/Add-ADSubnet.ps1 b/AD-SITE-Add-ADSubnet(ADSI)/Add-ADSubnet.ps1 index 6306b4c9..b2756ddc 100644 --- a/AD-SITE-Add-ADSubnet(ADSI)/Add-ADSubnet.ps1 +++ b/AD-SITE-Add-ADSubnet(ADSI)/Add-ADSubnet.ps1 @@ -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 diff --git a/AD-SITE-Find_Missing_Subnets/AD-Find_missing_subnets_in_ActiveDirectory.ps1 b/AD-SITE-Find_Missing_Subnets/AD-Find_missing_subnets_in_ActiveDirectory.ps1 index 2efb2241..62537259 100644 --- a/AD-SITE-Find_Missing_Subnets/AD-Find_missing_subnets_in_ActiveDirectory.ps1 +++ b/AD-SITE-Find_Missing_Subnets/AD-Find_missing_subnets_in_ActiveDirectory.ps1 @@ -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) diff --git a/AD-SITE-Get-ADSIComputerSite/Get-ADSIComputerSite.ps1 b/AD-SITE-Get-ADSIComputerSite/Get-ADSIComputerSite.ps1 index 58d45425..686ba86d 100644 --- a/AD-SITE-Get-ADSIComputerSite/Get-ADSIComputerSite.ps1 +++ b/AD-SITE-Get-ADSIComputerSite/Get-ADSIComputerSite.ps1 @@ -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 diff --git a/AD-SITE-Get-ADSiteInventory/Get-ADSiteInventory.ps1 b/AD-SITE-Get-ADSiteInventory/Get-ADSiteInventory.ps1 index 43c361d7..7081de56 100644 --- a/AD-SITE-Get-ADSiteInventory/Get-ADSiteInventory.ps1 +++ b/AD-SITE-Get-ADSiteInventory/Get-ADSiteInventory.ps1 @@ -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 { diff --git a/AD-USER-Get-ADDirectReport/Get-ADDirectReport.ps1 b/AD-USER-Get-ADDirectReport/Get-ADDirectReport.ps1 index eb96b600..d9d925ad 100644 --- a/AD-USER-Get-ADDirectReport/Get-ADDirectReport.ps1 +++ b/AD-USER-Get-ADDirectReport/Get-ADDirectReport.ps1 @@ -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 diff --git a/AD-USER-Get-AccountLockedOut/AD-USER-Get-AccountLockedOut.ps1 b/AD-USER-Get-AccountLockedOut/AD-USER-Get-AccountLockedOut.ps1 index 105056c6..73e4def6 100644 --- a/AD-USER-Get-AccountLockedOut/AD-USER-Get-AccountLockedOut.ps1 +++ b/AD-USER-Get-AccountLockedOut/AD-USER-Get-AccountLockedOut.ps1 @@ -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) diff --git a/AD-USER-Report_Expiring_users/AD-USER-Report_Expiring_users.ps1 b/AD-USER-Report_Expiring_users/AD-USER-Report_Expiring_users.ps1 index f780da60..fce93d0e 100644 --- a/AD-USER-Report_Expiring_users/AD-USER-Report_Expiring_users.ps1 +++ b/AD-USER-Report_Expiring_users/AD-USER-Report_Expiring_users.ps1 @@ -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) @@ -158,7 +158,7 @@ BEGIN { $SMTPClient.EnableSsl = $true } - # Credential Paramenter + # Credential Parameter #IF (($PSBoundParameters['Username']) -and ($PSBoundParameters['Password'])) { IF ($PSBoundParameters['Credential']) { # Create Credential Object diff --git a/AZURE-AppService-Update_RestrictionIP/AppService-Update_RestrictionIP.ps1 b/AZURE-AppService-Update_RestrictionIP/AppService-Update_RestrictionIP.ps1 index 4d8f7015..675a479c 100644 --- a/AZURE-AppService-Update_RestrictionIP/AppService-Update_RestrictionIP.ps1 +++ b/AZURE-AppService-Update_RestrictionIP/AppService-Update_RestrictionIP.ps1 @@ -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. diff --git a/AZURE-Get-AzureIPRangesAndServiceTags/Get-AzureIPRangesAndServiceTags.ps1 b/AZURE-Get-AzureIPRangesAndServiceTags/Get-AzureIPRangesAndServiceTags.ps1 index 356c29df..1ed68f6f 100644 --- a/AZURE-Get-AzureIPRangesAndServiceTags/Get-AzureIPRangesAndServiceTags.ps1 +++ b/AZURE-Get-AzureIPRangesAndServiceTags/Get-AzureIPRangesAndServiceTags.ps1 @@ -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. diff --git a/AZURE-Policy-Invoke-ComplianceEvaluation/Invoke-ComplianceEvaluation.ps1 b/AZURE-Policy-Invoke-ComplianceEvaluation/Invoke-ComplianceEvaluation.ps1 index 218f2cbd..635964c4 100644 --- a/AZURE-Policy-Invoke-ComplianceEvaluation/Invoke-ComplianceEvaluation.ps1 +++ b/AZURE-Policy-Invoke-ComplianceEvaluation/Invoke-ComplianceEvaluation.ps1 @@ -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 diff --git a/EXCHANGE-Connect-ExchangeOnPremises/Connect-ExchangeOnPremises.ps1 b/EXCHANGE-Connect-ExchangeOnPremises/Connect-ExchangeOnPremises.ps1 index f4082fed..93348b8c 100644 --- a/EXCHANGE-Connect-ExchangeOnPremises/Connect-ExchangeOnPremises.ps1 +++ b/EXCHANGE-Connect-ExchangeOnPremises/Connect-ExchangeOnPremises.ps1 @@ -26,6 +26,7 @@ function Connect-ExchangeOnPremises { .LINK https://github.com/lazywinadmin/PowerShell #> + [CmdletBinding()] PARAM ( [Parameter(Mandatory, HelpMessage = 'http:///powershell')] [system.string]$ConnectionUri, diff --git a/EXCHANGE-Connect-ExchangeOnline/Connect-ExchangeOnline.ps1 b/EXCHANGE-Connect-ExchangeOnline/Connect-ExchangeOnline.ps1 index 003ad27f..afb84f3e 100644 --- a/EXCHANGE-Connect-ExchangeOnline/Connect-ExchangeOnline.ps1 +++ b/EXCHANGE-Connect-ExchangeOnline/Connect-ExchangeOnline.ps1 @@ -27,6 +27,7 @@ function Connect-ExchangeOnline { https://github.com/lazywinadmin/PowerShell #> + [CmdletBinding()] param ( [system.string]$ConnectionUri = 'https://ps.outlook.com/powershell/', diff --git a/SCCM-Get-SCCMClientCacheInformation/Get-SCCMClientCacheInformation.ps1 b/SCCM-Get-SCCMClientCacheInformation/Get-SCCMClientCacheInformation.ps1 index d0bb4ff0..564e4272 100644 --- a/SCCM-Get-SCCMClientCacheInformation/Get-SCCMClientCacheInformation.ps1 +++ b/SCCM-Get-SCCMClientCacheInformation/Get-SCCMClientCacheInformation.ps1 @@ -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 @@ -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 } } } diff --git a/SCCM-Set-SCCMClientCacheLocation/Set-SCCMClientCacheLocation.ps1 b/SCCM-Set-SCCMClientCacheLocation/Set-SCCMClientCacheLocation.ps1 index 21ce7caa..d538bc37 100644 --- a/SCCM-Set-SCCMClientCacheLocation/Set-SCCMClientCacheLocation.ps1 +++ b/SCCM-Set-SCCMClientCacheLocation/Set-SCCMClientCacheLocation.ps1 @@ -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, @@ -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']) { diff --git a/SCCM-Set-SCCMClientCacheSize/Set-SCCMClientCacheSize.ps1 b/SCCM-Set-SCCMClientCacheSize/Set-SCCMClientCacheSize.ps1 index 26be51e7..a1da0e05 100644 --- a/SCCM-Set-SCCMClientCacheSize/Set-SCCMClientCacheSize.ps1 +++ b/SCCM-Set-SCCMClientCacheSize/Set-SCCMClientCacheSize.ps1 @@ -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 } } } diff --git a/TOOL-Clean-MacAddress/Clean-MacAddress.ps1 b/TOOL-Clean-MacAddress/Clean-MacAddress.ps1 index daa78182..41400e32 100644 --- a/TOOL-Clean-MacAddress/Clean-MacAddress.ps1 +++ b/TOOL-Clean-MacAddress/Clean-MacAddress.ps1 @@ -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 diff --git a/TOOL-Disable-RemoteDesktop/Disable-RemoteDesktop.ps1 b/TOOL-Disable-RemoteDesktop/Disable-RemoteDesktop.ps1 index ad3bad67..bd165992 100644 --- a/TOOL-Disable-RemoteDesktop/Disable-RemoteDesktop.ps1 +++ b/TOOL-Disable-RemoteDesktop/Disable-RemoteDesktop.ps1 @@ -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() diff --git a/TOOL-Enable-RemoteDesktop/Enable-RemoteDesktop.ps1 b/TOOL-Enable-RemoteDesktop/Enable-RemoteDesktop.ps1 index a31f9a2b..14173485 100644 --- a/TOOL-Enable-RemoteDesktop/Enable-RemoteDesktop.ps1 +++ b/TOOL-Enable-RemoteDesktop/Enable-RemoteDesktop.ps1 @@ -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() diff --git a/TOOL-Expand-GzipFile/Expand-GzipFile.ps1 b/TOOL-Expand-GzipFile/Expand-GzipFile.ps1 index 958d37fe..a5b72f97 100644 --- a/TOOL-Expand-GzipFile/Expand-GzipFile.ps1 +++ b/TOOL-Expand-GzipFile/Expand-GzipFile.ps1 @@ -41,12 +41,11 @@ Function Expand-GZipFile { $output.Write($buffer, 0, $read) } - $GzipStream.Close() - $output.Close() - $FileStreamIn.Close() } catch { throw $_ + } + finally { if ($GzipStream) { $GzipStream.Close() } if ($output) { $output.Close() } if ($FileStreamIn) { $FileStreamIn.Close() } diff --git a/TOOL-Get-ComputerInfo/Get-ComputerInfo.ps1 b/TOOL-Get-ComputerInfo/Get-ComputerInfo.ps1 index 7522b5a7..b385b6df 100644 --- a/TOOL-Get-ComputerInfo/Get-ComputerInfo.ps1 +++ b/TOOL-Get-ComputerInfo/Get-ComputerInfo.ps1 @@ -18,7 +18,7 @@ function Get-ComputerInfo { Processor(s) (NumberOfProcessors), Number of Socket(s) (NumberOfSockets), and Number of Core(s) (NumberOfCores). - This function as been tested against Windows Server 2000, 2003, 2008 and 2012 + This function has been tested against Windows Server 2000, 2003, 2008 and 2012 .PARAMETER ComputerName Specify a ComputerName or IP Address. Default is Localhost. diff --git a/TOOL-Get-LocalGroupMember/Get-LocalGroupMember.ps1 b/TOOL-Get-LocalGroupMember/Get-LocalGroupMember.ps1 index 47730d15..50bdaab4 100644 --- a/TOOL-Get-LocalGroupMember/Get-LocalGroupMember.ps1 +++ b/TOOL-Get-LocalGroupMember/Get-LocalGroupMember.ps1 @@ -17,7 +17,7 @@ function Get-LocalGroupMember { To Add: Credential param - Resurce Local and AD using ADSI or ActiveDirectory Module + Resource Local and AD using ADSI or ActiveDirectory Module OnlyUser param .LINK https://github.com/lazywinadmin/PowerShell diff --git a/TOOL-Get-PendingReboot/Get-PendingReboot.ps1 b/TOOL-Get-PendingReboot/Get-PendingReboot.ps1 index 831ff548..c3477780 100644 --- a/TOOL-Get-PendingReboot/Get-PendingReboot.ps1 +++ b/TOOL-Get-PendingReboot/Get-PendingReboot.ps1 @@ -8,7 +8,7 @@ Function Get-PendingReboot { system is pending a reboot, from either Microsoft Patching or a Software Installation. For Windows 2008+ the function will query the CBS registry key as another factor in determining pending reboot state. "PendingFileRenameOperations" and "Auto Update\RebootRequired" are observed - as being consistant across Windows Server 2003 & 2008. + as being consistent across Windows Server 2003 & 2008. CBServicing = Component Based Servicing (Windows 2008) WindowsUpdate = Windows Update / Auto Update (Windows 2003 / 2008) diff --git a/TOOL-Get-Uptime/Get-Uptime.ps1 b/TOOL-Get-Uptime/Get-Uptime.ps1 index 10d23864..eb680f6e 100644 --- a/TOOL-Get-Uptime/Get-Uptime.ps1 +++ b/TOOL-Get-Uptime/Get-Uptime.ps1 @@ -162,7 +162,7 @@ function Get-Uptime { 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() diff --git a/TOOL-New-CimSmartSession/New-CimSmartSession.ps1 b/TOOL-New-CimSmartSession/New-CimSmartSession.ps1 index 959358cb..33ed6e6c 100644 --- a/TOOL-New-CimSmartSession/New-CimSmartSession.ps1 +++ b/TOOL-New-CimSmartSession/New-CimSmartSession.ps1 @@ -53,7 +53,7 @@ function New-CimSmartSession { Write-Output "[$(Get-Date -Format 'yyyy/MM/dd-HH:mm:ss:ff')][$((Get-Variable -Scope 1 -Name MyInvocation -ValueOnly).MyCommand.Name)] $Message" }#Get-DefaultMessage - # Create a containter (hashtable) for the properties (Splatting) + # Create a container (hashtable) for the properties (Splatting) $CIMSessionSplatting = @{ } # Credential specified @@ -89,7 +89,7 @@ function New-CimSmartSession { TRY { Write-Verbose -Message (Get-DefaultMessage -Message "$Computer - Connecting using DCOM protocol") - New-CimSession @SessionParams -errorVariable ErrorProcessNewCimSessionDCOM + New-CimSession @CIMSessionSplatting -errorVariable ErrorProcessNewCimSessionDCOM } CATCH { IF ($ErrorProcessNewCimSessionDCOM) { Write-Warning -Message (Get-DefaultMessage -Message "$Computer - Can't connect using DCOM protocol either") } @@ -97,7 +97,7 @@ function New-CimSmartSession { } FINALLY { # Remove the CimSessionOption for the DCOM protocol for the next computer - $CIMSessionSplatting.Remove('CIMSessionOption') + $CIMSessionSplatting.Remove('SessionOption') } }#ELSE }#Test-Connection diff --git a/TOOL-New-DjoinFile/New-DjoinFile.ps1 b/TOOL-New-DjoinFile/New-DjoinFile.ps1 index 7299456a..b6a9e1ce 100644 --- a/TOOL-New-DjoinFile/New-DjoinFile.ps1 +++ b/TOOL-New-DjoinFile/New-DjoinFile.ps1 @@ -6,7 +6,7 @@ function New-DjoinFile { .DESCRIPTION Function to generate a blob file accepted by djoin.exe tool (offline domain join) - This function can create a file compatible with djoin with the Blob initially provisionned. + This function can create a file compatible with djoin with the Blob initially provisioned. .PARAMETER Blob Specifies the blob generated by djoin diff --git a/TOOL-New-Password/New-Password.ps1 b/TOOL-New-Password/New-Password.ps1 index 5ed7ea70..c1959d7d 100644 --- a/TOOL-New-Password/New-Password.ps1 +++ b/TOOL-New-Password/New-Password.ps1 @@ -69,7 +69,7 @@ function New-Password { $NewPassWord = $(foreach ($i in 1..$length) { Get-Random -InputObject $PassWordChars }) -join '' }#Do UNTIL ( - # Make sure it contains an Upercase and Lowercase letter, a number and another special character + # Make sure it contains an Uppercase and Lowercase letter, a number and another special character ($NewPassword -cmatch '[A-Z]') -and ($NewPassWord -cmatch '[a-z]') -and ($NewPassWord -imatch '[0-9]') -and diff --git a/TOOL-Out-Excel/Out-Excel.ps1 b/TOOL-Out-Excel/Out-Excel.ps1 index fc4a4e47..df12400f 100644 --- a/TOOL-Out-Excel/Out-Excel.ps1 +++ b/TOOL-Out-Excel/Out-Excel.ps1 @@ -22,6 +22,8 @@ TODO: #> [CmdletBinding()] PARAM ( + [Parameter(ValueFromPipeline)] + [psobject]$InputObject, [string[]]$property, [switch]$raw ) @@ -39,7 +41,7 @@ TODO: } PROCESS { - if ($_ -eq $null) { return } + if ($InputObject -eq $null) { return } if ($Row -eq 1) { # when we see the first object, we need to build our header table if (-not $property) { @@ -47,13 +49,13 @@ TODO: # we’ll build one from the object’s properties $property = @() if ($raw) { - $_.properties.PropertyNames | + $InputObject.properties.PropertyNames | ForEach-Object -Process { $property += @($_) } } else { - $_.PsObject.get_properties() | + $InputObject.PsObject.get_properties() | ForEach-Object -Process { $property += @($_.Name.ToString()) } @@ -81,13 +83,12 @@ TODO: # and load the data into the correct cell in the current row. # this way we don’t have to worry about missing properties # or the “ordering” of the properties - if ($thisColumn -eq $HeaderHash[$header]) { - if ($raw) { - $Sheet.Cells.Item($Row, $thisColumn) = [string]$_.properties.$header - } - else { - $Sheet.Cells.Item($Row, $thisColumn) = [string]$_.$header - } + $thisColumn = $HeaderHash[$header] + if ($raw) { + $Sheet.Cells.Item($Row, $thisColumn) = [string]$InputObject.properties.$header + } + else { + $Sheet.Cells.Item($Row, $thisColumn) = [string]$InputObject.$header } } } diff --git a/TOOL-Send-Email/TOOL-Send-Email.ps1 b/TOOL-Send-Email/TOOL-Send-Email.ps1 index bafd9dbd..3957c0a6 100644 --- a/TOOL-Send-Email/TOOL-Send-Email.ps1 +++ b/TOOL-Send-Email/TOOL-Send-Email.ps1 @@ -46,7 +46,7 @@ function Send-Email { Specifies the text encoding of the title and the body. .PARAMETER Attachment - Specifies if an attachement must be added to the function + Specifies if an attachment must be added to the message .PARAMETER Credential Specifies the credential to use, default will use the current credential. @@ -61,7 +61,7 @@ function Send-Email { Specifies if the email must be sent using SSL. .PARAMETER DeliveryNotificationOptions - Specifies the delivey notification options. + Specifies the delivery notification options. https://msdn.microsoft.com/en-us/library/system.net.mail.deliverynotificationoptions.aspx .PARAMETER EmailCC @@ -261,7 +261,7 @@ function Send-Email { } } - # Attachement Parameter + # Attachment Parameter IF ($PSBoundParameters['attachment']) { $SMTPattachment = New-Object -TypeName System.Net.Mail.Attachment($attachment) $SMTPMessage.Attachments.Add($SMTPattachment) @@ -282,7 +282,7 @@ function Send-Email { $SMTPClient.EnableSsl = $true } - # Credential Paramenter + # Credential Parameter #IF (($PSBoundParameters['Username']) -and ($PSBoundParameters['Password'])) IF ($PSBoundParameters['Credential']) { <# diff --git a/TOOL-Set-NetworkLevelAuthentication/Set-NetworkLevelAuthentication.ps1 b/TOOL-Set-NetworkLevelAuthentication/Set-NetworkLevelAuthentication.ps1 index f9a38888..1f575aef 100644 --- a/TOOL-Set-NetworkLevelAuthentication/Set-NetworkLevelAuthentication.ps1 +++ b/TOOL-Set-NetworkLevelAuthentication/Set-NetworkLevelAuthentication.ps1 @@ -67,7 +67,7 @@ function Set-NetworkLevelAuthentication { Write-Verbose -message $Computer TRY { # Building Splatting for CIM Sessions - Write-Verbose -message "$Computer - CIM/WIM - Building Splatting" + Write-Verbose -message "$Computer - CIM/WMI - Building Splatting" $CIMSessionParams = @{ ComputerName = $Computer ErrorAction = 'Stop' @@ -118,7 +118,7 @@ function Set-NetworkLevelAuthentication { }#CATCH FINALLY { if ($CimSession) { - # CLeanup/Close the remaining session + # Cleanup/Close the remaining session Write-Verbose -Message "[PROCESS] Finally Close any CIM Session(s)" Remove-CimSession -CimSession $CimSession } diff --git a/TOOL-Sync-Wsus-Client/Sync-WsusClient.ps1 b/TOOL-Sync-Wsus-Client/Sync-WsusClient.ps1 index 81cd5fed..b622e6ca 100644 --- a/TOOL-Sync-Wsus-Client/Sync-WsusClient.ps1 +++ b/TOOL-Sync-Wsus-Client/Sync-WsusClient.ps1 @@ -28,6 +28,7 @@ function sync-WsusClient { Here's one place where it came from: http://pleasework.robbievance.net/howto-force-really-wsus-clients-to-check-in-on-demand/ Roger P Seekell, (2019), 9-13-2019 #> +[CmdletBinding()] Param( [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] @@ -39,6 +40,7 @@ process { $scriptBlock = { try { $updateSession = New-Object -com "Microsoft.Update.Session" + $criteria = "IsInstalled=0" $null = $updateSession.CreateUpdateSearcher().Search($criteria).UPdates #I don't want to see them wuauclt /reportnow "$env:computername - Done!" diff --git a/TOOL-Test-RemoteDesktopIsEnabled/Test-RemoteDesktopIsEnabled.ps1 b/TOOL-Test-RemoteDesktopIsEnabled/Test-RemoteDesktopIsEnabled.ps1 index d713de64..c4bcf004 100644 --- a/TOOL-Test-RemoteDesktopIsEnabled/Test-RemoteDesktopIsEnabled.ps1 +++ b/TOOL-Test-RemoteDesktopIsEnabled/Test-RemoteDesktopIsEnabled.ps1 @@ -24,6 +24,7 @@ function Test-RemoteDesktopIsEnabled { #> + [CmdletBinding()] PARAM( [String[]]$ComputerName = $env:COMPUTERNAME ) @@ -34,7 +35,7 @@ function Test-RemoteDesktopIsEnabled { ComputerName = $Computer NameSpace = "root\cimv2\TerminalServices" } - # Enable Remote Desktop + # Read AllowTsConnections [boolean](Get-WmiObject -Class Win32_TerminalServiceSetting @Splatting).AllowTsConnections # Disable requirement that user must be authenticated diff --git a/_Profiles/Microsoft.PowerShell_profile.ps1 b/_Profiles/Microsoft.PowerShell_profile.ps1 index cf1ecce5..2602afa0 100644 --- a/_Profiles/Microsoft.PowerShell_profile.ps1 +++ b/_Profiles/Microsoft.PowerShell_profile.ps1 @@ -60,7 +60,7 @@ Import-Module -Name PSReadline if (Get-Module -name PSReadline) { # Set Shortcuts for History Search # Start typing, for example "Get-" then press up and down arrow, it'll show all - # commands in my story that started by "Get-" + # commands in my history that started by "Get-" Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward Set-PSReadlineOption -EditMode Windows diff --git a/_Template/Get-Something.ps1 b/_Template/Get-Something.ps1 index 522b67dd..35c7d845 100644 --- a/_Template/Get-Something.ps1 +++ b/_Template/Get-Something.ps1 @@ -21,7 +21,7 @@ Function Get-Something { lazywinadmin.com @lazywinadmin - 1.0 | 2016/00/00 | Francois-Xavier Cat + 1.0 | 2016/01/01 | Francois-Xavier Cat Initial Version #> [CmdletBinding()]