fix lint issues
This commit is contained in:
parent
12f84144eb
commit
fc6c35a4c4
@ -1,9 +1,4 @@
|
|||||||
function New-CSCertAttribute {
|
function New-CSCertAttribute {
|
||||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
|
||||||
'PSUseShouldProcessForStateChangingFunctions',
|
|
||||||
'',
|
|
||||||
Justification = 'Returns a new object and does not change data'
|
|
||||||
)]
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Creates required data for a certificate signing request.
|
Creates required data for a certificate signing request.
|
||||||
@ -51,6 +46,11 @@ function New-CSCertAttribute {
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSUseShouldProcessForStateChangingFunctions',
|
||||||
|
'',
|
||||||
|
Justification = 'Returns a new object and does not change data'
|
||||||
|
)]
|
||||||
[OutputType('PSCredentialStore.Certificate.Attribute')]
|
[OutputType('PSCredentialStore.Certificate.Attribute')]
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
|
@ -61,6 +61,11 @@ function Connect-To {
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSAvoidGlobalVars',
|
||||||
|
'',
|
||||||
|
Justification = 'Wrapping existing var from WinSCP module.'
|
||||||
|
)]
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||||
@ -114,7 +119,9 @@ function Connect-To {
|
|||||||
|
|
||||||
# First check the optional modules
|
# First check the optional modules
|
||||||
if (-not (Resolve-Dependency -Name $Type)) {
|
if (-not (Resolve-Dependency -Name $Type)) {
|
||||||
Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f $Type) -ErrorAction 'Stop'
|
Write-Error -Message (
|
||||||
|
"Could not resolve the optional dependencies defined for {0}" -f $Type
|
||||||
|
) -ErrorAction 'Stop'
|
||||||
}
|
}
|
||||||
switch ($Type) {
|
switch ($Type) {
|
||||||
"VMware" {
|
"VMware" {
|
||||||
@ -146,7 +153,10 @@ function Connect-To {
|
|||||||
|
|
||||||
catch {
|
catch {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to look up credential store item for RemoteHost {0}/Identifier {1}!" -f $RemoteHost, $Identifier
|
Message = (
|
||||||
|
"Unable to look up credential store item for RemoteHost " +
|
||||||
|
("{0}/Identifier {1}!" -f $RemoteHost, $Identifier)
|
||||||
|
)
|
||||||
ErrorAction = 'Stop'
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
@ -198,7 +208,10 @@ function Connect-To {
|
|||||||
if (!($WinSCPSession.Opened)) {
|
if (!($WinSCPSession.Opened)) {
|
||||||
# Check the connection state and find out if the session is still open.
|
# Check the connection state and find out if the session is still open.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Connection to {0} using Type {1} was established. But now it seems to be lost!" -f $RemoteHost, $Type
|
Message = (
|
||||||
|
("Connection to {0} using Type {1} " -f $RemoteHost, $Type) +
|
||||||
|
"was established. But now it seems to be lost!"
|
||||||
|
)
|
||||||
ErrorAction = 'Stop'
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
@ -261,6 +274,8 @@ function Connect-To {
|
|||||||
ErrorAction = 'Stop'
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
|
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
|
||||||
|
# ScriptAnalyzer issue (unused var) workaround.
|
||||||
|
$null = $Global:PSExchangeRemote
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
@ -300,7 +315,9 @@ function Connect-To {
|
|||||||
try {
|
try {
|
||||||
$SessionOption = New-WinSCPSessionOption @WinSCPSessionParams
|
$SessionOption = New-WinSCPSessionOption @WinSCPSessionParams
|
||||||
$Global:WinSCPSession = New-WinSCPSession -SessionOption $SessionOption
|
$Global:WinSCPSession = New-WinSCPSession -SessionOption $SessionOption
|
||||||
Write-Verbose -Message ("SCP Connection established with {0}" -f $Global:WinSCPSession.Hostname)
|
Write-Verbose -Message (
|
||||||
|
"SCP Connection established with {0}" -f $Global:WinSCPSession.Hostname
|
||||||
|
)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
@ -314,7 +331,10 @@ function Connect-To {
|
|||||||
if (!($WinSCPSession.Opened)) {
|
if (!($WinSCPSession.Opened)) {
|
||||||
# Check the connection state and find out if the session is still open.
|
# Check the connection state and find out if the session is still open.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Connection to {0} using Type {1} was established. But now it seems to be lost!" -f $RemoteHost, $Type
|
Message = (
|
||||||
|
("Connection to {0} using Type {1} was established. " -f $RemoteHost, $Type) +
|
||||||
|
"But now it seems to be lost!"
|
||||||
|
)
|
||||||
ErrorAction = 'Stop'
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
|
@ -52,6 +52,11 @@ function Disconnect-From {
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSAvoidGlobalVars',
|
||||||
|
'',
|
||||||
|
Justification = 'Wrapping existing global vars from external modules'
|
||||||
|
)]
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$RemoteHost,
|
[string]$RemoteHost,
|
||||||
@ -133,7 +138,9 @@ function Disconnect-From {
|
|||||||
"NetAppFAS" {
|
"NetAppFAS" {
|
||||||
try {
|
try {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Setting {0} to `$null, which will disconnect NetAppFAS" -f $Global:CurrentNcController
|
Message = (
|
||||||
|
"Setting {0} to `$null, which will disconnect NetAppFAS" -f $Global:CurrentNcController
|
||||||
|
)
|
||||||
ErrorAction = 'Continue'
|
ErrorAction = 'Continue'
|
||||||
}
|
}
|
||||||
Write-Verbose @MessageParams
|
Write-Verbose @MessageParams
|
||||||
|
@ -40,6 +40,11 @@ function Remove-CredentialStoreItem {
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSUseShouldProcessForStateChangingFunctions',
|
||||||
|
'',
|
||||||
|
Justification = 'Removes data from existing store.'
|
||||||
|
)]
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
@ -90,7 +95,7 @@ function Remove-CredentialStoreItem {
|
|||||||
$CredentialName = $RemoteHost
|
$CredentialName = $RemoteHost
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Get-Member -InputObject $CSContent -Name $CredentialName -Membertype NoteProperty) {
|
if (Get-Member -InputObject $CSContent -Name $CredentialName -MemberType NoteProperty) {
|
||||||
# We need to use the .NET Method because there is no easier way in PowerShell.
|
# We need to use the .NET Method because there is no easier way in PowerShell.
|
||||||
$CSContent.PSObject.Properties.Remove($CredentialName)
|
$CSContent.PSObject.Properties.Remove($CredentialName)
|
||||||
ConvertTo-Json -InputObject $CSContent -Depth 5 | Out-File -FilePath $Path -Encoding utf8
|
ConvertTo-Json -InputObject $CSContent -Depth 5 | Out-File -FilePath $Path -Encoding utf8
|
||||||
|
@ -33,7 +33,11 @@ function Get-DefaultCredentialStorePath {
|
|||||||
if ($IsMacOS) {
|
if ($IsMacOS) {
|
||||||
return Join-Path -Path '/var/opt' -ChildPath 'PSCredentialStore/CredentialStore.json'
|
return Join-Path -Path '/var/opt' -ChildPath 'PSCredentialStore/CredentialStore.json'
|
||||||
}
|
}
|
||||||
elseif (($isWindows) -or ($PSVersionTable.PSVersion.Major -lt 6) -or ($PSVersionTable.PSEdition -eq 'Desktop')) {
|
elseif (
|
||||||
|
($isWindows) -or
|
||||||
|
($PSVersionTable.PSVersion.Major -lt 6) -or
|
||||||
|
($PSVersionTable.PSEdition -eq 'Desktop')
|
||||||
|
) {
|
||||||
return Join-Path -Path $env:ProgramData -ChildPath 'PSCredentialStore/CredentialStore.json'
|
return Join-Path -Path $env:ProgramData -ChildPath 'PSCredentialStore/CredentialStore.json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,7 +48,11 @@ function Get-DefaultCredentialStorePath {
|
|||||||
if ($IsMacOS) {
|
if ($IsMacOS) {
|
||||||
return Join-Path -Path $Env:HOME -ChildPath 'CredentialStore.json'
|
return Join-Path -Path $Env:HOME -ChildPath 'CredentialStore.json'
|
||||||
}
|
}
|
||||||
elseif (($isWindows) -or ($PSVersionTable.PSVersion.Major -lt 6) -or ($PSVersionTable.PSEdition -eq 'Desktop')) {
|
elseif (
|
||||||
|
($isWindows) -or
|
||||||
|
($PSVersionTable.PSVersion.Major -lt 6) -or
|
||||||
|
($PSVersionTable.PSEdition -eq 'Desktop')
|
||||||
|
) {
|
||||||
return Join-Path -Path $env:AppData -ChildPath 'CredentialStore.json'
|
return Join-Path -Path $env:AppData -ChildPath 'CredentialStore.json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ function Import-CSPfxCertificate {
|
|||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This function is used to import existing pfx certificate files. The Import-PFXCertificate cmdlet from the
|
This function is used to import existing pfx certificate files. The Import-PFXCertificate cmdlet from the
|
||||||
PKI module imports the certificate into a deprecated store. Thus you can't read the private key afterwards or
|
PKI module imports the certificate into a deprecated store. Thus you can't read the private key afterwards
|
||||||
using it for decrypting data.
|
or using it for decrypting data.
|
||||||
|
|
||||||
.PARAMETER Path
|
.PARAMETER Path
|
||||||
Path to an existing *.pfx certificate file.
|
Path to an existing *.pfx certificate file.
|
||||||
@ -83,7 +83,9 @@ function Import-CSPfxCertificate {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (Test-CSPfxCertificate -Thumbprint $cert.Thumbprint) {
|
if (Test-CSPfxCertificate -Thumbprint $cert.Thumbprint) {
|
||||||
Write-Warning -Message ('The certificate with thumbprint {0} is already present!' -f $cert.Thumbprint)
|
Write-Warning -Message (
|
||||||
|
'The certificate with thumbprint {0} is already present!' -f $cert.Thumbprint
|
||||||
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$Store.Add($cert)
|
$Store.Add($cert)
|
||||||
|
@ -36,7 +36,9 @@ function Resolve-Dependency {
|
|||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
If (-not (Resolve-Dependency -Name 'VMware')) {
|
If (-not (Resolve-Dependency -Name 'VMware')) {
|
||||||
Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f 'VMware') -ErrorAction 'Stop'
|
Write-Error -Message (
|
||||||
|
"Could not resolve the optional dependencies defined for {0}" -f 'VMware'
|
||||||
|
) -ErrorAction 'Stop'
|
||||||
}
|
}
|
||||||
#>
|
#>
|
||||||
|
|
||||||
@ -60,6 +62,8 @@ function Resolve-Dependency {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
# ScriptAnalyzer issue workaround (unused var)
|
||||||
|
$null = $Name
|
||||||
$SelectedDependency = $Dependency.Optional | Where-Object { $_.Name -match $Name }
|
$SelectedDependency = $Dependency.Optional | Where-Object { $_.Name -match $Name }
|
||||||
# return true if there is no dependency defined
|
# return true if there is no dependency defined
|
||||||
if ($null -eq $SelectedDependency) {
|
if ($null -eq $SelectedDependency) {
|
||||||
|
@ -64,6 +64,8 @@ function Test-CSPfxCertificate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
# Script analyzer issue (unused var) workaround
|
||||||
|
$null = $Thumbprint
|
||||||
$Cert = $Store.Certificates | Where-Object { $_.Thumbprint -eq $Thumbprint }
|
$Cert = $Store.Certificates | Where-Object { $_.Thumbprint -eq $Thumbprint }
|
||||||
|
|
||||||
if ($null -eq $Cert) {
|
if ($null -eq $Cert) {
|
||||||
|
Loading…
Reference in New Issue
Block a user