Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit 6912559

Browse files
authored
Remove old Write-Message2 function (#13)
1 parent cb11209 commit 6912559

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/Connection/Connect-To.ps1

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,23 @@ function Connect-To {
142142
}
143143

144144
catch {
145-
Write-Message2 ("Unable to look up credential store item for RemoteHost {0}/Identifier {1}!" -f $RemoteHost, $Identifier) -ErrorAction Stop
145+
$MessageParams = @{
146+
Message = "Unable to look up credential store item for RemoteHost {0}/Identifier {1}!" -f $RemoteHost, $Identifier
147+
ErrorAction = "Stop"
148+
}
149+
Write-Error @MessageParams
146150
}
147151
}
148152
else {
149153
$creds = $Credentials
150154
}
151155

152156
if ($creds.UserName -eq "" -or $creds.Password.GetType().Name -ne "SecureString") {
153-
# Write a error message to the log.
154-
Write-Message2 ("Please provide valid credentials for RemoteHost {0}!" -f $RemoteHost) -ErrorAction Stop
157+
$MessageParams = @{
158+
Message = "Please provide valid credentials for RemoteHost {0}!" -f $RemoteHost
159+
ErrorAction = "Stop"
160+
}
161+
Write-Error @MessageParams
155162
}
156163
else {
157164
switch ($Type) {
@@ -162,8 +169,11 @@ function Connect-To {
162169
}
163170

164171
catch {
165-
# Write a error message to the log.
166-
Write-Message2 ("Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type) -ErrorAction Stop
172+
$MessageParams = @{
173+
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
174+
ErrorAction = "Stop"
175+
}
176+
Write-Error @MessageParams
167177
}
168178
}
169179
"FTP" {

0 commit comments

Comments
 (0)