Patch/Send-PatchInfo.ps1
# <# # .SYNOPSIS # Sends information about installed patch to a remote server # .DESCRIPTION # Sends information about installed patch to a remote server defined by Register-PatchHelper command # .EXAMPLE # Send-PatchInfo -patchLevel "NC" -patchNumber 123 # .NOTES # #> # function Send-PatchInfo { # [Alias("sdpai")] # [CmdletBinding()] # param( # [Parameter(Mandatory, ParameterSetName = "patch")] # [string]$patchLevel, # [Parameter(Mandatory, ParameterSetName = "patch")] # [int]$patchNumber, # [Parameter(Mandatory, ParameterSetName = "extension")] # [string]$ExtensionName, # [Parameter(Mandatory, ParameterSetName = "extension")] # [string]$ExtensionVersion # ) # begin { # $ErrorActionPreference = "Stop" # # Fetching certificate # $cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where-Object -Property Issuer -EQ -Value "CN=ADS Russia LLC" # if (!$cert) { # $cert = Get-ChildItem -Path "Cert:\LocalMachine\My" | Where-Object -Property Issuer -EQ -Value "CN=ADS Russia LLC" # if (!$cert) { throw "Certificate not found." } # } # $cert | Write-Verbose # #endregion # } # process { # if ($patchLevel -eq 1) { $patchLevel = "NC" } else { $patchLevel = "NML" } # $reportUrl = "$($PatchHelperConfig.ReportURL)/report" # $body = @{} # if ($PSCmdlet.ParameterSetName -eq 'patch') { # $reportUrl += "/patches" # $body = @{ # "CustomerName" = $PatchHelperConfig.CustomerName # "PatchLevel" = $patchLevel # "PatchNumber" = $patchNumber # } | ConvertTo-Json # } # else { # $reportUrl += "/extensions" # $body = @{ # "CustomerName" = $PatchHelperConfig.CustomerName # "ExtensionName" = $ExtensionName # "ExtensionVersion" = $ExtensionVersion # } | ConvertTo-Json # } # $ProgressPreferenceBack = $ProgressPreference; $ProgressPreference = "SilentlyContinue"; # Invoke-WebRequest -Uri $reportUrl -UseDefaultCredentials -Method Post -ContentType "application/json" -Body $body -Certificate $cert -UseBasicParsing | Out-Null # $ProgressPreference = $ProgressPreferenceBack; # } # end { # } # } # Export-ModuleMember -Alias * -Function * |