Skip to content

Commit b786864

Browse files
committed
Modernizing and fixing bugs
1 parent 09ba3b1 commit b786864

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Publish.ps1

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ foreach ($item in $moduleFolders){
6464
}
6565

6666
if($testModuleFailed) {}
67-
elseif($moduleStatus -ne "") {-and !$testModuleFailed
68-
Write-Warning "$($moduleName): $moduleStatus" testModuleFailed
67+
elseif($moduleStatus -ne "") {
68+
Write-Warning "$($moduleName): $moduleStatus"
6969
}
7070
else {
7171
$modulesToPublish += $item
@@ -77,13 +77,14 @@ if ($modulesToPublish.Count -gt 0){
7777

7878
Import-Module (Join-Path $PSScriptRoot /Modules/IntelliTect.CredentialManager)
7979
$credential = Get-CredentialManagerCredential "pstoolbox" -ErrorAction SilentlyContinue
80-
81-
if (!$PowerShellGalleryAPIKey) {
82-
$PowerShellGalleryAPIKey = ([PSCredential]$credential).GetNetworkCredential().Password
80+
81+
if (!$PowerShellGalleryAPIKey -and $credential) {
82+
$PowerShellGalleryAPIKey = ([PSCredential]$credential).GetNetworkCredential().Password
8383
}
8484

8585
if(!$PowerShellGalleryAPIKey) {
86-
$PowerShellGalleryAPIKey = Read-Host "Enter your PS Gallery API Key"
86+
$PowerShellGalleryAPIKey = Read-Host "Enter your PS Gallery API Key" -AsSecureString
87+
$EncryptedInput = ConvertFrom-SecureString -String $PowerShellGalleryAPIKey
8788
}
8889

8990
if (!$PowerShellGalleryAPIKey) {
@@ -92,12 +93,12 @@ if ($modulesToPublish.Count -gt 0){
9293

9394
if ($SaveAPIKey) {
9495
if ($PowerShellGalleryAPIKey -and $SaveAPIKey) {
95-
$cred = New-Object System.Management.Automation.PSCredential "intellitect", ($PowerShellGalleryAPIKey | ConvertTo-SecureString -AsPlainText -Force)
96+
$cred = New-Object System.Management.Automation.PSCredential "intellitect", ($PowerShellGalleryAPIKey | ConvertTo-SecureString -String $EncryptedInput)
9697
Set-CredentialManagerCredential -TargetName "pstoolbox" -Credential $cred
9798
}
9899
}
99-
100-
foreach ($item in $modulesToPublish) {
100+
101+
foreach ($item in $modulesToPublish) {
101102
Publish-Module -Path $item.FullName -NuGetApiKey $PowerShellGalleryAPIKey
102103
}
103104
Write-Progress -Activity "Publish IntelliTect Module" -Completed

0 commit comments

Comments
 (0)