diff --git a/Hawk/functions/General/Update-HawkModule.ps1 b/Hawk/functions/General/Update-HawkModule.ps1 index 86cc78f..5be7da8 100644 --- a/Hawk/functions/General/Update-HawkModule.ps1 +++ b/Hawk/functions/General/Update-HawkModule.ps1 @@ -46,7 +46,7 @@ else { Out-LogFile "Checking for latest version online" -Action - $onlineversion = Find-Module -name Hawk -erroraction silentlycontinue + $onlineversion = Find-Module -Name Hawk -ErrorAction silentlycontinue $Localversion = (Get-Module Hawk | Sort-Object -Property Version -Descending)[0] Out-LogFile ("Found Version " + $onlineversion.version + " Online") -Information diff --git a/Hawk/functions/Tenant/Search-HawkTenantActivityByIP.ps1 b/Hawk/functions/Tenant/Search-HawkTenantActivityByIP.ps1 index 72dd868..bd4baa9 100644 --- a/Hawk/functions/Tenant/Search-HawkTenantActivityByIP.ps1 +++ b/Hawk/functions/Tenant/Search-HawkTenantActivityByIP.ps1 @@ -85,7 +85,7 @@ { # Expand out the Data and convert from JSON - [array]$ipeventsexpanded = $ipevents | Select-object -ExpandProperty AuditData | ConvertFrom-Json + [array]$ipeventsexpanded = $ipevents | Select-Object -ExpandProperty AuditData | ConvertFrom-Json Out-LogFile ("Found " + $ipeventsexpanded.count + " related to provided IP" ) -Information $ipeventsexpanded | Out-MultipleFileType -FilePrefix "All_Events" -csv -json -User $DirectoryName diff --git a/Hawk/functions/User/Get-HawkUserExchangeSearchQuery.ps1 b/Hawk/functions/User/Get-HawkUserExchangeSearchQuery.ps1 index 7fac10c..921ca78 100644 --- a/Hawk/functions/User/Get-HawkUserExchangeSearchQuery.ps1 +++ b/Hawk/functions/User/Get-HawkUserExchangeSearchQuery.ps1 @@ -82,7 +82,7 @@ $ExchangeSearchesSimple = $ExchangeSearches | Get-SimpleUnifiedAuditLog #Export both raw and simplistic views to specified user's folder - $ExchangeSearches | Select-Object -ExpandProperty AuditData | Convertfrom-Json | Out-MultipleFileType -FilePrefix "ExchangeSearchQueries_$User" -User $User -csv -json + $ExchangeSearches | Select-Object -ExpandProperty AuditData | ConvertFrom-Json | Out-MultipleFileType -FilePrefix "ExchangeSearchQueries_$User" -User $User -csv -json $ExchangeSearchesSimple | Out-MultipleFileType -FilePrefix "Simple_ExchangeSearchQueries_$User" -User $User -csv -json } else diff --git a/Hawk/functions/User/Get-HawkUserMailItemsAccessed.ps1 b/Hawk/functions/User/Get-HawkUserMailItemsAccessed.ps1 index 7a2a2a8..d8e50da 100644 --- a/Hawk/functions/User/Get-HawkUserMailItemsAccessed.ps1 +++ b/Hawk/functions/User/Get-HawkUserMailItemsAccessed.ps1 @@ -80,7 +80,7 @@ $MailboxItemsAccessedSimple = $MailboxItemsAccessed | Get-SimpleUnifiedAuditLog #Export both raw and simplistic views to specified user's folder - $MailboxItemsAccessed | Select-Object -ExpandProperty AuditData | Convertfrom-Json | Out-MultipleFileType -FilePrefix "MailItemsAccessed_$User" -User $User -csv -json + $MailboxItemsAccessed | Select-Object -ExpandProperty AuditData | ConvertFrom-Json | Out-MultipleFileType -FilePrefix "MailItemsAccessed_$User" -User $User -csv -json $MailboxItemsAccessedSimple | Out-MultipleFileType -FilePrefix "Simple_MailItemsAccessed_$User" -User $User -csv -json } else diff --git a/Hawk/functions/User/Get-HawkUserMailSendActivity.ps1 b/Hawk/functions/User/Get-HawkUserMailSendActivity.ps1 index dc13e40..0bd4b7f 100644 --- a/Hawk/functions/User/Get-HawkUserMailSendActivity.ps1 +++ b/Hawk/functions/User/Get-HawkUserMailSendActivity.ps1 @@ -81,7 +81,7 @@ $ExchangeSendsSimple = $ExchangeSends | Get-SimpleUnifiedAuditLog #Export both raw and simplistic views to specified user's folder - $ExchangeSends | Select-Object -ExpandProperty AuditData | Convertfrom-Json | Out-MultipleFileType -FilePrefix "SendActivity_$User" -User $User -csv -json + $ExchangeSends | Select-Object -ExpandProperty AuditData | ConvertFrom-Json | Out-MultipleFileType -FilePrefix "SendActivity_$User" -User $User -csv -json $ExchangeSendsSimple | Out-MultipleFileType -FilePrefix "Simple_SendActivity_$User" -User $User -csv -json } else diff --git a/Hawk/functions/User/Get-HawkUserPWNCheck.ps1 b/Hawk/functions/User/Get-HawkUserPWNCheck.ps1 index f6f53db..89a5596 100644 --- a/Hawk/functions/User/Get-HawkUserPWNCheck.ps1 +++ b/Hawk/functions/User/Get-HawkUserPWNCheck.ps1 @@ -71,7 +71,7 @@ #https://haveibeenpwned.com/API/v3#ResponseCodes contains the response codes for the API try { - $Result = Invoke-WebRequest -Uri $InvokeURL -Headers $headers -userAgent 'Hawk' -ErrorAction Stop + $Result = Invoke-WebRequest -Uri $InvokeURL -Headers $headers -UserAgent 'Hawk' -ErrorAction Stop } catch { @@ -81,17 +81,17 @@ { NotFound { - write-host "Email Provided Not Found in Pwned Database" + Write-Host "Email Provided Not Found in Pwned Database" return } Unauthorized { - write-host "Unauthorised Access - API key provided is not valid or has expired" + Write-Host "Unauthorised Access - API key provided is not valid or has expired" return } Default { - write-host $ErrorMessage + Write-Host $ErrorMessage return } } diff --git a/Hawk/functions/User/Get-HawkUserSharePointSearchQuery.ps1 b/Hawk/functions/User/Get-HawkUserSharePointSearchQuery.ps1 index 294d0d8..88db693 100644 --- a/Hawk/functions/User/Get-HawkUserSharePointSearchQuery.ps1 +++ b/Hawk/functions/User/Get-HawkUserSharePointSearchQuery.ps1 @@ -81,7 +81,7 @@ $SharePointSearchesSimple = $SharePointSearches | Get-SimpleUnifiedAuditLog #Export both raw and simplistic views to specified user's folder - $SharePointSearches | Select-Object -ExpandProperty AuditData | Convertfrom-Json | Out-MultipleFileType -FilePrefix "SharePointSearches_$User" -User $User -csv -json + $SharePointSearches | Select-Object -ExpandProperty AuditData | ConvertFrom-Json | Out-MultipleFileType -FilePrefix "SharePointSearches_$User" -User $User -csv -json $SharePointSearchesSimple | Out-MultipleFileType -FilePrefix "Simple_SharePointSearches_$User" -User $User -csv -json } else diff --git a/Hawk/internal/WorkInProgress/Get-HawkTenantInboxRule.ps1 b/Hawk/internal/WorkInProgress/Get-HawkTenantInboxRule.ps1 index 5442011..611087e 100644 --- a/Hawk/internal/WorkInProgress/Get-HawkTenantInboxRule.ps1 +++ b/Hawk/internal/WorkInProgress/Get-HawkTenantInboxRule.ps1 @@ -86,7 +86,7 @@ } # Get the exo PS session - $exopssession = get-pssession | Where-Object { ($_.ConfigurationName -eq 'Microsoft.Exchange') -and ($_.State -eq 'Opened') } + $exopssession = Get-PSSession | Where-Object { ($_.ConfigurationName -eq 'Microsoft.Exchange') -and ($_.State -eq 'Opened') } # Gather all of the mailboxes Out-LogFile "Getting all Mailboxes" -Action diff --git a/Hawk/internal/WorkInProgress/Get-HawkTenantMailItemsAccessed.ps1 b/Hawk/internal/WorkInProgress/Get-HawkTenantMailItemsAccessed.ps1 index 36eea0e..be51109 100644 --- a/Hawk/internal/WorkInProgress/Get-HawkTenantMailItemsAccessed.ps1 +++ b/Hawk/internal/WorkInProgress/Get-HawkTenantMailItemsAccessed.ps1 @@ -56,7 +56,7 @@ { $MailboxItemsAccessed = Get-AllUnifiedAuditLogEntry -UnifiedSearch ("Search-UnifiedAuditLog -Operations 'MailItemsAccessed' -FreeText $ApplicationID ") - $MailboxItemsAccessed | Select-Object -ExpandProperty AuditData | Convertfrom-Json | Out-MultipleFileType -FilePrefix "MailItemsAccessed" -csv -json + $MailboxItemsAccessed | Select-Object -ExpandProperty AuditData | ConvertFrom-Json | Out-MultipleFileType -FilePrefix "MailItemsAccessed" -csv -json }#End Process END diff --git a/Hawk/internal/configurations/configuration.ps1 b/Hawk/internal/configurations/configuration.ps1 index 4589780..f0e46f7 100644 --- a/Hawk/internal/configurations/configuration.ps1 +++ b/Hawk/internal/configurations/configuration.ps1 @@ -20,7 +20,7 @@ $handler = { $paramSetPSFLoggingProvider = @{ Name = 'logfile' InstanceName = 'Hawk' - FilePath = Join-Path -path $args[0] -ChildPath '%date%_logs.csv' + FilePath = Join-Path -Path $args[0] -ChildPath '%date%_logs.csv' TimeFormat = 'yyyy-MM-dd HH:mm:ss.fff' IncludeModules = 'Hawk' UTC = $true diff --git a/Hawk/internal/functions/Add-HawkAppData.ps1 b/Hawk/internal/functions/Add-HawkAppData.ps1 index ba8ca5c..97535c1 100644 --- a/Hawk/internal/functions/Add-HawkAppData.ps1 +++ b/Hawk/internal/functions/Add-HawkAppData.ps1 @@ -28,7 +28,7 @@ Function Add-HawkAppData Out-LogFile ("Adding " + $value + " to " + $Name + " in HawkAppData") -Action # Test if our HawkAppData variable exists - if ([bool](get-variable HawkAppData -ErrorAction SilentlyContinue)) + if ([bool](Get-Variable HawkAppData -ErrorAction SilentlyContinue)) { $global:HawkAppData | Add-Member -MemberType NoteProperty -Name $Name -Value $Value } diff --git a/Hawk/internal/functions/Compress-HawkData.ps1 b/Hawk/internal/functions/Compress-HawkData.ps1 index 3fdd115..b693dd7 100644 --- a/Hawk/internal/functions/Compress-HawkData.ps1 +++ b/Hawk/internal/functions/Compress-HawkData.ps1 @@ -46,7 +46,7 @@ Function Compress-HawkData #Out-LogFile ("Found " + $allfiles.count + " files to add to zip") # create the zip file name - [string]$zipname = "Hawk_" + (Split-path $Hawk.filepath -Leaf) + ".zip" + [string]$zipname = "Hawk_" + (Split-Path $Hawk.filepath -Leaf) + ".zip" [string]$zipfullpath = Join-Path $env:TEMP $zipname Out-LogFile ("Creating temporary zip file " + $zipfullpath) diff --git a/Hawk/internal/functions/Convert-ReportToHTML.ps1 b/Hawk/internal/functions/Convert-ReportToHTML.ps1 index d627397..f1e16c5 100644 --- a/Hawk/internal/functions/Convert-ReportToHTML.ps1 +++ b/Hawk/internal/functions/Convert-ReportToHTML.ps1 @@ -30,11 +30,11 @@ Function Convert-ReportToHTML begin { # Make sure that the files are there - if (!(test-path $Xml)) + if (!(Test-Path $Xml)) { Write-Error "XML File not found for conversion" -ErrorAction Stop } - if (!(test-path $Xsl)) + if (!(Test-Path $Xsl)) { Write-Error "XSL File not found for Conversion" -ErrorAction Stop } @@ -43,7 +43,7 @@ Function Convert-ReportToHTML process { # Create the output file name - $OutputFile = Join-Path (Split-path $xml) ((split-path $xml -Leaf).split(".")[0] + ".html") + $OutputFile = Join-Path (Split-Path $xml) ((Split-Path $xml -Leaf).split(".")[0] + ".html") # Run the transform on the XML and produce the HTML $xslt = New-Object System.Xml.Xsl.XslCompiledTransform diff --git a/Hawk/internal/functions/Get-AllUnifiedAuditLogEntry.ps1 b/Hawk/internal/functions/Get-AllUnifiedAuditLogEntry.ps1 index 6328202..c574577 100644 --- a/Hawk/internal/functions/Get-AllUnifiedAuditLogEntry.ps1 +++ b/Hawk/internal/functions/Get-AllUnifiedAuditLogEntry.ps1 @@ -33,7 +33,7 @@ } # build our search command to execute - $cmd = $UnifiedSearch + " -StartDate `'" + (get-date ($StartDate) -UFormat %m/%d/%Y) + "`' -EndDate `'" + (get-date ($endDate) -UFormat %m/%d/%Y) + "`' -SessionCommand ReturnLargeSet -resultsize 5000 -sessionid " + (Get-Date -UFormat %H%M%S) + $cmd = $UnifiedSearch + " -StartDate `'" + (Get-Date ($StartDate) -UFormat %m/%d/%Y) + "`' -EndDate `'" + (Get-Date ($endDate) -UFormat %m/%d/%Y) + "`' -SessionCommand ReturnLargeSet -resultsize 5000 -sessionid " + (Get-Date -UFormat %H%M%S) Out-LogFile ("Running Unified Audit Log Search") -Action Out-Logfile $cmd -NoDisplay diff --git a/Hawk/internal/functions/Get-IPGeolocation.ps1 b/Hawk/internal/functions/Get-IPGeolocation.ps1 index e73934d..25e6812 100644 --- a/Hawk/internal/functions/Get-IPGeolocation.ps1 +++ b/Hawk/internal/functions/Get-IPGeolocation.ps1 @@ -22,7 +22,7 @@ Function Get-IPGeolocation ) # If we don't have a HawkAppData variable then we need to read it in - if (!([bool](get-variable HawkAppData -erroraction silentlycontinue))) + if (!([bool](Get-Variable HawkAppData -ErrorAction silentlycontinue))) { Read-HawkAppData } @@ -54,7 +54,7 @@ Function Get-IPGeolocation } elseif ($IPAddress -eq "") { - write-Verbose ("Null IP Provided: " + $IPAddress) + Write-Verbose ("Null IP Provided: " + $IPAddress) $hash = @{ IP = $IPAddress CountryName = "NULL IP" @@ -73,7 +73,7 @@ Function Get-IPGeolocation # Return Data from web $Error.Clear() - $geoip = Invoke-RestMethod -Method Get -URI $resource -ErrorAction SilentlyContinue + $geoip = Invoke-RestMethod -Method Get -Uri $resource -ErrorAction SilentlyContinue if (($Error.Count -gt 0) -or ($null -eq $geoip.type)) { diff --git a/Hawk/internal/functions/Import-AzureAuthenticationLog.ps1 b/Hawk/internal/functions/Import-AzureAuthenticationLog.ps1 index a72f9fd..d930a17 100644 --- a/Hawk/internal/functions/Import-AzureAuthenticationLog.ps1 +++ b/Hawk/internal/functions/Import-AzureAuthenticationLog.ps1 @@ -40,7 +40,7 @@ Function Import-AzureAuthenticationLog $processedentry = New-Object -TypeName PSobject # Look at each member of the entry ... we want to process each in turn and add them to a new object - foreach ($member in ($entry | get-member -MemberType NoteProperty)) + foreach ($member in ($entry | Get-Member -MemberType NoteProperty)) { # Identity unique properties and add to property list of base object if not present @@ -67,7 +67,7 @@ Function Import-AzureAuthenticationLog if ($baseproperties -contains $object.name) { } else { - $baseproperties.add($object.name) | out-null + $baseproperties.add($object.name) | Out-Null } # For some entries a property can appear in ExtendedProperties and as a normal property @@ -137,7 +137,7 @@ Function Import-AzureAuthenticationLog } Creationtime { - $processedentry | Add-Member -MemberType NoteProperty -Name CreationTime -value (get-date $entry.Creationtime -format g) + $processedentry | Add-Member -MemberType NoteProperty -Name CreationTime -Value (Get-Date $entry.Creationtime -Format g) } Default { @@ -172,7 +172,7 @@ Function Import-AzureAuthenticationLog { switch ($propertyname) { - CreationTime { $baseobject | Add-Member -MemberType NoteProperty -Name $propertyname -Value (get-date 01/01/1900 -format g) } + CreationTime { $baseobject | Add-Member -MemberType NoteProperty -Name $propertyname -Value (Get-Date 01/01/1900 -Format g) } Default { $baseobject | Add-Member -MemberType NoteProperty -Name $propertyname -Value "Base" } } } diff --git a/Hawk/internal/functions/Out-HawkAppData.ps1 b/Hawk/internal/functions/Out-HawkAppData.ps1 index 81c1ecd..2fc497f 100644 --- a/Hawk/internal/functions/Out-HawkAppData.ps1 +++ b/Hawk/internal/functions/Out-HawkAppData.ps1 @@ -15,11 +15,11 @@ #> Function Out-HawkAppData { - $HawkAppdataPath = join-path $env:LOCALAPPDATA "Hawk\Hawk.json" - $HawkAppdataFolder = join-path $env:LOCALAPPDATA "Hawk" + $HawkAppdataPath = Join-Path $env:LOCALAPPDATA "Hawk\Hawk.json" + $HawkAppdataFolder = Join-Path $env:LOCALAPPDATA "Hawk" # test if the folder exists - if (test-path $HawkAppdataFolder) { } + if (Test-Path $HawkAppdataFolder) { } # if it doesn't we need to create it else { diff --git a/Hawk/internal/functions/Out-LogFile.ps1 b/Hawk/internal/functions/Out-LogFile.ps1 index ca460d4..6986bce 100644 --- a/Hawk/internal/functions/Out-LogFile.ps1 +++ b/Hawk/internal/functions/Out-LogFile.ps1 @@ -125,7 +125,7 @@ [switch]$NoNewLine ) - Write-PSFMessage -Message $string -ModuleName Hawk -FunctionName (Get-PSCallstack)[1].FunctionName + Write-PSFMessage -Message $string -ModuleName Hawk -FunctionName (Get-PSCallStack)[1].FunctionName # Make sure we have the Hawk Global Object if ([string]::IsNullOrEmpty($Hawk.FilePath)) @@ -134,7 +134,7 @@ } # Get our log file path - $LogFile = Join-path $Hawk.FilePath "Hawk.log" + $LogFile = Join-Path $Hawk.FilePath "Hawk.log" $ScreenOutput = -not $NoDisplay $LogOutput = $true @@ -201,7 +201,7 @@ { if ($NoNewLine) { - Write-Host $logstring -InformationAction Continue -NoNewLine + Write-Host $logstring -InformationAction Continue -NoNewline } else { diff --git a/Hawk/internal/functions/Out-MultipleFileType.ps1 b/Hawk/internal/functions/Out-MultipleFileType.ps1 index 9c3cba3..63a7059 100644 --- a/Hawk/internal/functions/Out-MultipleFileType.ps1 +++ b/Hawk/internal/functions/Out-MultipleFileType.ps1 @@ -61,9 +61,9 @@ Function Out-MultipleFileType # Set the output path if ([string]::IsNullOrEmpty($User)) { - $path = join-path $Hawk.filepath "\Tenant" + $path = Join-Path $Hawk.filepath "\Tenant" # Test the path if it is there do nothing otherwise create it - if (test-path $path) { } + if (Test-Path $path) { } else { Out-LogFile ("Making output directory for Tenant " + $Path) -Action @@ -72,7 +72,7 @@ Function Out-MultipleFileType } else { - $path = join-path $Hawk.filepath $user + $path = Join-Path $Hawk.filepath $user # Set a bool so we know this is a user output [bool]$UserOutput = $true @@ -80,7 +80,7 @@ Function Out-MultipleFileType [string]$ShortUser = ($User.split('@'))[0] # Test the path if it is there do nothing otherwise create it - if (test-path $path) { } + if (Test-Path $path) { } else { Out-LogFile ("Making output directory for user " + $Path) -Action @@ -111,8 +111,8 @@ Function Out-MultipleFileType if ($xml -eq $true) { # lets put the xml files in a seperate directory to not clutter things up - $xmlpath = Join-path $Path XML - if (Test-path $xmlPath) { } + $xmlpath = Join-Path $Path XML + if (Test-Path $xmlPath) { } else { Out-LogFile ("Making output directory for xml files " + $xmlPath) -Action diff --git a/Hawk/internal/functions/Out-Report.ps1 b/Hawk/internal/functions/Out-Report.ps1 index eb36fa6..84c1813 100644 --- a/Hawk/internal/functions/Out-Report.ps1 +++ b/Hawk/internal/functions/Out-Report.ps1 @@ -43,7 +43,7 @@ # Set our output path # Single report file for all outputs user/tenant/etc. # This might change in the future??? - $reportpath = Join-path $hawk.filepath report.xml + $reportpath = Join-Path $hawk.filepath report.xml # Switch statement to handle the state to color mapping switch ($State) @@ -55,14 +55,14 @@ } # Check if we have our XSL file in the output directory - $xslpath = Join-path $hawk.filepath Report.xsl + $xslpath = Join-Path $hawk.filepath Report.xsl if (Test-Path $xslpath ) { } else { # Copy the XSL file into the current output path - $sourcepath = join-path (split-path (Get-Module Hawk).path) report.xsl - if (test-path $sourcepath) + $sourcepath = Join-Path (Split-Path (Get-Module Hawk).path) report.xsl + if (Test-Path $sourcepath) { Copy-Item -Path $sourcepath -Destination $hawk.filepath } @@ -75,10 +75,10 @@ # See if we have already created a report file # If so we need to import it - if (Test-path $reportpath) + if (Test-Path $reportpath) { $reportxml = $null - [xml]$reportxml = get-content $reportpath + [xml]$reportxml = Get-Content $reportpath } # Since we have NOTHING we will create a new XML and just add / save / and exit else diff --git a/Hawk/internal/functions/Read-HawkAppData.ps1 b/Hawk/internal/functions/Read-HawkAppData.ps1 index 197d666..314e2c3 100644 --- a/Hawk/internal/functions/Read-HawkAppData.ps1 +++ b/Hawk/internal/functions/Read-HawkAppData.ps1 @@ -15,10 +15,10 @@ #> Function Read-HawkAppData { - $HawkAppdataPath = join-path $env:LOCALAPPDATA "Hawk\Hawk.json" + $HawkAppdataPath = Join-Path $env:LOCALAPPDATA "Hawk\Hawk.json" # check to see if our xml file is there - if (test-path $HawkAppdataPath) + if (Test-Path $HawkAppdataPath) { Out-LogFile ("Reading file " + $HawkAppdataPath) -Action $global:HawkAppData = ConvertFrom-Json -InputObject ([string](Get-Content $HawkAppdataPath)) diff --git a/Hawk/internal/functions/Start-SleepWithProgress.ps1 b/Hawk/internal/functions/Start-SleepWithProgress.ps1 index aedfa78..2c92d9a 100644 --- a/Hawk/internal/functions/Start-SleepWithProgress.ps1 +++ b/Hawk/internal/functions/Start-SleepWithProgress.ps1 @@ -28,7 +28,7 @@ Function Start-SleepWithProgress Write-Progress -Activity "Sleeping" -CurrentOperation "$Timeleft More Seconds" -PercentComplete (($i / $sleeptime) * 100) # Sleep 1 second - start-sleep 1 + Start-Sleep 1 } Write-Progress -Completed -Activity "Sleeping" diff --git a/Hawk/internal/functions/Test-MicrosoftIP.ps1 b/Hawk/internal/functions/Test-MicrosoftIP.ps1 index 9e82246..8af7021 100644 --- a/Hawk/internal/functions/Test-MicrosoftIP.ps1 +++ b/Hawk/internal/functions/Test-MicrosoftIP.ps1 @@ -34,7 +34,7 @@ Function Test-MicrosoftIP Out-Logfile "Building MSFTIPList" -Action # Load our networking dll pulled from https://github.com/lduchosal/ipnetwork - [string]$dll = join-path (Split-path (((get-module Hawk)[0]).path) -Parent) "\bin\System.Net.IPNetwork.dll" + [string]$dll = Join-Path (Split-Path (((Get-Module Hawk)[0]).path) -Parent) "\bin\System.Net.IPNetwork.dll" $Error.Clear() Out-LogFile ("Loading Networking functions from " + $dll) -Action @@ -48,7 +48,7 @@ Function Test-MicrosoftIP $Error.clear() - $MSFTJSON = (Invoke-WebRequest -uri ("https://endpoints.office.com/endpoints/Worldwide?ClientRequestId=" + (new-guid).ToString())).content | ConvertFrom-Json + $MSFTJSON = (Invoke-WebRequest -Uri ("https://endpoints.office.com/endpoints/Worldwide?ClientRequestId=" + (New-Guid).ToString())).content | ConvertFrom-Json if ($Error.Count -gt 0) { diff --git a/Hawk/internal/functions/Test-OperationEnabled.ps1 b/Hawk/internal/functions/Test-OperationEnabled.ps1 index 539fb8d..3b4e367 100644 --- a/Hawk/internal/functions/Test-OperationEnabled.ps1 +++ b/Hawk/internal/functions/Test-OperationEnabled.ps1 @@ -49,7 +49,7 @@ ) # Verify the provided User has the specified Operation enabled - $TestResult = Get-Mailbox -Identity $User | Where-Object -Property AuditOwner -eq $Operation + $TestResult = Get-Mailbox -Identity $User | Where-Object -Property AuditOwner -EQ $Operation if ($null -eq $TestResult) { diff --git a/Hawk/internal/functions/Test-UserObject.ps1 b/Hawk/internal/functions/Test-UserObject.ps1 index 298322d..14943ec 100644 --- a/Hawk/internal/functions/Test-UserObject.ps1 +++ b/Hawk/internal/functions/Test-UserObject.ps1 @@ -43,7 +43,7 @@ Function Test-UserObject } # Case 3 - Array of objects # Validate that at least one object in the array contains a UserPrincipalName Property - elseif ([bool](get-member -inputobject $ToTest[0] -name UserPrincipalName -MemberType Properties)) + elseif ([bool](Get-Member -InputObject $ToTest[0] -Name UserPrincipalName -MemberType Properties)) { Return $ToTest } diff --git a/Hawk/tests/general/FileIntegrity.Tests.ps1 b/Hawk/tests/general/FileIntegrity.Tests.ps1 index 407409d..40062f8 100644 --- a/Hawk/tests/general/FileIntegrity.Tests.ps1 +++ b/Hawk/tests/general/FileIntegrity.Tests.ps1 @@ -29,7 +29,7 @@ Describe "Verifying integrity of module files" { { if ($PSVersionTable.PSVersion.Major -lt 6) { - [byte[]]$byte = get-content -Encoding byte -ReadCount 4 -TotalCount 4 -Path $Path + [byte[]]$byte = Get-Content -Encoding byte -ReadCount 4 -TotalCount 4 -Path $Path } else { @@ -46,7 +46,7 @@ Describe "Verifying integrity of module files" { } Context "Validating PS1 Script files" { - $allFiles = Get-ChildItem -Path $script:moduleRoot -Recurse | Where-Object Name -like "*.ps1" | Where-Object FullName -NotLike "$script:moduleRoot\tests\*" + $allFiles = Get-ChildItem -Path $script:moduleRoot -Recurse | Where-Object Name -Like "*.ps1" | Where-Object FullName -NotLike "$script:moduleRoot\tests\*" foreach ($file in $allFiles) { @@ -77,7 +77,7 @@ Describe "Verifying integrity of module files" { } Context "Validating help.txt help files" { - $allFiles = Get-ChildItem -Path $script:moduleRoot -Recurse | Where-Object Name -like "*.help.txt" | Where-Object FullName -NotLike "$script:moduleRoot\tests\*" + $allFiles = Get-ChildItem -Path $script:moduleRoot -Recurse | Where-Object Name -Like "*.help.txt" | Where-Object FullName -NotLike "$script:moduleRoot\tests\*" foreach ($file in $allFiles) { diff --git a/Hawk/tests/general/Help.Tests.ps1 b/Hawk/tests/general/Help.Tests.ps1 index a9e37f4..f0d023b 100644 --- a/Hawk/tests/general/Help.Tests.ps1 +++ b/Hawk/tests/general/Help.Tests.ps1 @@ -47,7 +47,7 @@ Param ( if ($SkipTest) { return } . $ExceptionsFile -$includedNames = (Get-ChildItem $CommandPath -Recurse -File | Where-Object Name -like "*.ps1").BaseName +$includedNames = (Get-ChildItem $CommandPath -Recurse -File | Where-Object Name -Like "*.ps1").BaseName $commandTypes = @('Cmdlet', 'Function') if ($PSVersionTable.PSEdition -eq 'Desktop' ) { $commandTypes += 'Workflow' } $commands = Get-Command -Module (Get-Module $ModuleName) -CommandType $commandTypes | Where-Object Name -In $includedNames @@ -92,7 +92,7 @@ foreach ($command in $commands) $common = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable' - $parameters = $command.ParameterSets.Parameters | Sort-Object -Property Name -Unique | Where-Object Name -notin $common + $parameters = $command.ParameterSets.Parameters | Sort-Object -Property Name -Unique | Where-Object Name -NotIn $common $parameterNames = $parameters.Name $HelpParameterNames = $Help.Parameters.Parameter.Name | Sort-Object -Unique foreach ($parameter in $parameters) diff --git a/Hawk/tests/general/Manifest.Tests.ps1 b/Hawk/tests/general/Manifest.Tests.ps1 index dd13d87..fe4c681 100644 --- a/Hawk/tests/general/Manifest.Tests.ps1 +++ b/Hawk/tests/general/Manifest.Tests.ps1 @@ -2,7 +2,7 @@ $moduleRoot = (Resolve-Path "$global:testroot\..").Path $manifest = ((Get-Content "$moduleRoot\Hawk.psd1") -join "`n") | Invoke-Expression Context "Basic resources validation" { - $files = Get-ChildItem "$moduleRoot\functions" -Recurse -File | Where-Object Name -like "*.ps1" + $files = Get-ChildItem "$moduleRoot\functions" -Recurse -File | Where-Object Name -Like "*.ps1" It "Exports all functions in the public folder" -TestCases @{ files = $files; manifest = $manifest } { $functions = (Compare-Object -ReferenceObject $files.BaseName -DifferenceObject $manifest.FunctionsToExport | Where-Object SideIndicator -Like '<=').InputObject $functions | Should -BeNullOrEmpty diff --git a/Hawk/tests/pester.ps1 b/Hawk/tests/pester.ps1 index 3602906..4100a30 100644 --- a/Hawk/tests/pester.ps1 +++ b/Hawk/tests/pester.ps1 @@ -40,7 +40,7 @@ $config.TestResult.Enabled = $true if ($TestGeneral) { Write-PSFMessage -Level Important -Message "Modules imported, proceeding with general tests" - foreach ($file in (Get-ChildItem "$PSScriptRoot\general" | Where-Object Name -like "*.Tests.ps1")) + foreach ($file in (Get-ChildItem "$PSScriptRoot\general" | Where-Object Name -Like "*.Tests.ps1")) { if ($file.Name -notlike $Include) { continue } if ($file.Name -like $Exclude) { continue } @@ -55,7 +55,7 @@ if ($TestGeneral) { $totalRun += $result.TotalCount $totalFailed += $result.FailedCount - $result.Tests | Where-Object Result -ne 'Passed' | ForEach-Object { + $result.Tests | Where-Object Result -NE 'Passed' | ForEach-Object { $testresults += [pscustomobject]@{ Block = $_.Block Name = "It $($_.Name)" @@ -77,8 +77,8 @@ if ($TestFunctions) Write-PSFMessage -Level Important -Message "Proceeding with individual tests" # Get both regular and internal function tests $testFiles = @( - Get-ChildItem "$PSScriptRoot\functions" -Recurse -File | Where-Object Name -like "*Tests.ps1" - Get-ChildItem "$PSScriptRoot\internal\functions" -Recurse -File | Where-Object Name -like "*Tests.ps1" + Get-ChildItem "$PSScriptRoot\functions" -Recurse -File | Where-Object Name -Like "*Tests.ps1" + Get-ChildItem "$PSScriptRoot\internal\functions" -Recurse -File | Where-Object Name -Like "*Tests.ps1" ) foreach ($file in $testFiles) { @@ -96,7 +96,7 @@ if ($TestFunctions) { $totalRun += $result.TotalCount $totalFailed += $result.FailedCount - $result.Tests | Where-Object Result -ne 'Passed' | ForEach-Object { + $result.Tests | Where-Object Result -NE 'Passed' | ForEach-Object { $testresults += [pscustomobject]@{ Block = $_.Block Name = "It $($_.Name)" diff --git a/install.ps1 b/install.ps1 index 43ad4db..d617f12 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1035,7 +1035,7 @@ PreparingToExpandVerboseMessage=Preparing to expand... if ($innerException -eq $null) { - $exception = New-object System.IO.IOException $errorMessage + $exception = New-Object System.IO.IOException $errorMessage } else { @@ -2181,7 +2181,7 @@ PreparingToExpandVerboseMessage=Preparing to expand... if ($innerException -eq $null) { - $exception = New-object System.IO.IOException $errorMessage + $exception = New-Object System.IO.IOException $errorMessage } else {