Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Value / Error on Remove-WifiProfile #28

Open
roborobs1023 opened this issue Oct 26, 2021 · 1 comment
Open

Return Value / Error on Remove-WifiProfile #28

roborobs1023 opened this issue Oct 26, 2021 · 1 comment

Comments

@roborobs1023
Copy link

roborobs1023 commented Oct 26, 2021

Looking to retrieve a value based on whether a WifiProfile was successfully removed or their was an error. For instance if the Profile did not exist I want to have it return an error. I'm not seeing any way in the documentation to access this information currently.

Example would be:

try { Remove-WifiProfile -ProfileName $WifiProfile } catch { Write-Host ("Profile does not exist. Please enter Wifi Profile again.") $WifiProfile = Read-Host ("Wifi Profile") }

@mkht
Copy link
Contributor

mkht commented Nov 10, 2021

Is this what you're looking for?
If you want to use try-catch to get the errors of the PowerShell command, you need the -ErrorAction Stop parameter.

try { Remove-WifiProfile -ProfileName $WifiProfile -ErrorAction Stop } catch { Write-Host ("Profile does not exist. Please enter Wifi Profile again."); $WifiProfile = Read-Host ("Wifi Profile") }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants