This repository was archived by the owner on Jul 6, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff 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" {
You can’t perform that action at this time.
0 commit comments