diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 4ae6220..c99311e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -32,15 +32,6 @@ body: placeholder: e.g. v1.1.1 validations: required: true - - type: dropdown - id: pwsh_version - attributes: - label: PowerShell version - description: This can be found by running `$PSVersionTable` in PowerShell. If you don't see your version here, it's not supported. - options: - - '5.1' - - '6.x' - - '7.x' validations: required: true - type: input diff --git a/.github/scripts/pssa-settings.psd1 b/.github/scripts/pssa-settings.psd1 index 18da217..8081c6b 100644 --- a/.github/scripts/pssa-settings.psd1 +++ b/.github/scripts/pssa-settings.psd1 @@ -18,24 +18,16 @@ Enable = $true # PowerShell platforms we want to check compatibility with TargetProfiles = @( - 'win-8_x64_10.0.14393.0_5.1.14393.2791_x64_4.0.30319.42000_framework', # PowerShell 5.1 on Windows Server 2016 - 'win-8_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework', # PowerShell 5.1 on Windows Server 2019 - 'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework'#, # PowerShell 5.1 on Windows 10 - #'win-8_x64_10.0.14393.0_6.2.4_x64_4.0.30319.42000_core', # PowerShell 6.2 on Windows Server 2016 - #'win-8_x64_10.0.17763.0_6.2.4_x64_4.0.30319.42000_core', # PowerShell 6.2 on Windows Server 2019 - #'win-4_x64_10.0.18362.0_6.2.4_x64_4.0.30319.42000_core', # PowerShell 6.2 on Windows 10 - #'win-8_x64_10.0.14393.0_7.0.0_x64_3.1.2_core', # PowerShell 7.0 on Windows Server 2016 - #'win-8_x64_10.0.17763.0_7.0.0_x64_3.1.2_core', # PowerShell 7.0 on Server 2019 - #'win-4_x64_10.0.18362.0_7.0.0_x64_3.1.2_core' # PowerShell 7.0 on Windows 10 + 'win-8_x64_10.0.14393.0_7.0.0_x64_3.1.2_core', # PowerShell 7.0 on Windows Server 2016 + 'win-8_x64_10.0.17763.0_7.0.0_x64_3.1.2_core', # PowerShell 7.0 on Server 2019 + 'win-4_x64_10.0.18362.0_7.0.0_x64_3.1.2_core' # PowerShell 7.0 on Windows 10 ) } PSUseCompatibleSyntax = @{ Enable = $true # PowerShell versions we want to check compatibility with TargetVersions = @( - '5.1'#, - #'6.2', - #'7.1' + '7.0' ) } PSPlaceCloseBrace = @{ diff --git a/Bootstrap.ps1 b/Bootstrap.ps1 index 19fbfbd..f7d0bc2 100644 --- a/Bootstrap.ps1 +++ b/Bootstrap.ps1 @@ -179,7 +179,7 @@ $vbrSessionLogger.UpdateSuccess($vbrLogEntry, '[VeeamNotify] Parsed job & sessio # Start a new new script in a new process with some of the information gathered here. # This allows Veeam to finish the current session faster and allows us gather information from the completed job. try { - $powershellExePath = (Get-Command -Name 'powershell.exe' -ErrorAction Stop).Path + $powershellExePath = (Get-Command -Name 'pwsh.exe' -ErrorAction Stop).Path Write-LogMessage -Tag 'INFO' -Message 'Launching AlertSender.ps1...' $vbrLogEntry = $vbrSessionLogger.AddLog('[VeeamNotify] Launching Alert Sender...') Start-Process -FilePath "$powershellExePath" -Verb runAs -ArgumentList $powershellArguments -WindowStyle hidden -ErrorAction Stop diff --git a/Installer.ps1 b/Installer.ps1 index 0f7ff8f..b2d99bf 100644 --- a/Installer.ps1 +++ b/Installer.ps1 @@ -260,11 +260,11 @@ function Get-InstallationSource { # Query release stream $releasePrompt = $true $releaseTypePrompt = @{ - Title = 'Release Selection' + Title = 'Release Selection' Description = "Which release type would you like to install?`nLatest stable: $latestStable`nLatest prerelease: $latestPrerelease" - Default = 'Yes' - OptionAKey = 'Stable' ; OptionATitle = 'Install Latest Stable' - OptionBKey = 'Prerelease' ; OptionBTitle = 'Install Latest Prerelease' + Default = 'Yes' + OptionAKey = 'Stable' ; OptionATitle = 'Install Latest Stable' + OptionBKey = 'Prerelease' ; OptionBTitle = 'Install Latest Prerelease' } if (YesNoPrompt @releaseTypePrompt) { $Latest = 'Release' diff --git a/README.md b/README.md index 4d94258..e33752c 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ As much relevant information as I've been able to discover from such backup sess ## Installation Requirements: -* Veeam Backup & Replication 12 or higher. -* PowerShell 5.1 or higher. +* Veeam Backup & Replication 12 or higher +* PowerShell 7 Please see the [How to Install](https://github.com/tigattack/VeeamNotify/wiki/%F0%9F%94%A7-How-to-Install) wiki page. diff --git a/Updater.ps1 b/Updater.ps1 index cacbfae..1de37b0 100644 --- a/Updater.ps1 +++ b/Updater.ps1 @@ -225,7 +225,7 @@ catch { } # Wait until the alert sender has finished running, or quit this if it's still running after 60s. It should never take that long. -while (Get-CimInstance win32_process -Filter "name='powershell.exe' and commandline like '%AlertSender.ps1%'") { +while (Get-CimInstance win32_process -Filter "name='pwsh.exe' and commandline like '%AlertSender.ps1%'") { $timer++ Start-Sleep -Seconds 1 if ($timer -eq '90') { diff --git a/resources/DeployVeeamConfiguration.ps1 b/resources/DeployVeeamConfiguration.ps1 index 295e6dc..f54fa14 100644 --- a/resources/DeployVeeamConfiguration.ps1 +++ b/resources/DeployVeeamConfiguration.ps1 @@ -89,8 +89,8 @@ function Update-JobWithFullPowershellPath { try { $jobOptions = $Job.GetOptions() - # Replace Powershell.exe with full path in a new variable for update. - $PostScriptFullPSPath = $PostScriptCmd -replace 'Powershell.exe', "$PowershellPath" + # Replace powershell.exe/pwsh.exe with full path in a new variable for update. + $PostScriptFullPSPath = $PostScriptCmd -replace 'powershell.exe', "$PowershellPath" -replace 'pwsh.exe', "$PowershellPath" # Set job to use modified post script path $jobOptions.JobScriptCommand.PostScriptCommandLine = $PostScriptFullPSPath $null = Set-VeeamJobOptions -Job $Job -Options $jobOptions @@ -217,8 +217,8 @@ function Set-BackupJobPostScript { # Check if job is already configured for VeeamNotify if ($postScriptCmd -eq $NewPostScriptCmd) { - # Check if job has full PowerShell.exe path - if ($postScriptCmd.StartsWith('powershell.exe', 'CurrentCultureIgnoreCase')) { + # Check if job has full powershell.exe/pwsh.exe path + if ($postScriptCmd.StartsWith('powershell.exe', 'CurrentCultureIgnoreCase') -or $postScriptCmd.StartsWith('pwsh.exe', 'CurrentCultureIgnoreCase')) { return Update-JobWithFullPowershellPath -Job $Job -PowershellPath $PowershellPath -PostScriptCmd $postScriptCmd } @@ -308,7 +308,7 @@ function Start-JobConfiguration { # Get PowerShell path try { - $powershellExePath = (Get-Command -Name 'powershell.exe' -ErrorAction Stop).Path + $powershellExePath = (Get-Command -Name 'pwsh.exe' -ErrorAction Stop).Path } catch { DeploymentError diff --git a/resources/NotificationBuilder.psm1 b/resources/NotificationBuilder.psm1 index 61d43c5..6f3ffa8 100644 --- a/resources/NotificationBuilder.psm1 +++ b/resources/NotificationBuilder.psm1 @@ -1,6 +1,6 @@ function New-Payload { [CmdletBinding()] - [OutputType([PSCustomObject])] + [OutputType([Hashtable])] param ( [Parameter(Mandatory)] [ValidateSet('Discord', 'Slack', 'Teams', 'Telegram', 'HTTP')] @@ -34,7 +34,7 @@ function New-Payload { function New-DiscordPayload { [CmdletBinding()] - [OutputType([PSCustomObject])] + [OutputType([Hashtable])] param ( [string]$JobName, [string]$JobType, @@ -216,7 +216,7 @@ function New-DiscordPayload { function New-TeamsPayload { [CmdletBinding()] - [OutputType([PSCustomObject])] + [OutputType([Hashtable])] param ( [string]$JobName, [string]$JobType, @@ -493,7 +493,7 @@ function New-TeamsPayload { function New-SlackPayload { [CmdletBinding()] - [OutputType([PSCustomObject])] + [OutputType([Hashtable])] param ( [string]$JobName, [string]$JobType, @@ -688,7 +688,7 @@ function New-SlackPayload { function New-TelegramPayload { [CmdletBinding()] - [OutputType([PSCustomObject])] + [OutputType([Hashtable])] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSReviewUnusedParameter', 'ThumbnailUrl', diff --git a/resources/NotificationSender.psm1 b/resources/NotificationSender.psm1 index 337347f..a855008 100644 --- a/resources/NotificationSender.psm1 +++ b/resources/NotificationSender.psm1 @@ -29,7 +29,7 @@ function Send-Payload { $postParams = @{ Uri = $Uri Method = $Method - UserAgent = "VeeamNotify; PowerShell/$psVersion" + UserAgent = "VeeamNotify (PowerShell/$psVersion)" ErrorAction = 'Stop' } diff --git a/tests/JsonValidator.Tests.ps1 b/tests/JsonValidator.Tests.ps1 index 7673380..2ed127d 100644 --- a/tests/JsonValidator.Tests.ps1 +++ b/tests/JsonValidator.Tests.ps1 @@ -1,8 +1,3 @@ -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSUseCompatibleCommands', - '', - Justification = 'Pester tests are run in modern PowerShell' -)] param () BeforeAll {