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

CUT-4344: Forget WiFi Network Command #613

Merged
merged 2 commits into from
Oct 15, 2024
Merged

Conversation

gweinjc
Copy link
Contributor

@gweinjc gweinjc commented Oct 15, 2024

Issues

  • CUT-4344 - Forget WiFi Network Command

What does this solve?

Creates a new Command template that should resolve the issue for customers using Radius and a user changes their password after connecting to a network and being unable to reconnect.

Is there anything particularly tricky?

Testing involves having RADIUS configured

How should this be tested?

  1. Have a RADIUS configuration enabled in your test tenant
  2. Have a user assigned to a device connect to the RADIUS network
  3. Change the user's password and attempt to reconnect (should not work)
  4. Distribute this command to the affected device
  5. Ensure that the command distributed correctly
    i. Command results should not indicate a failure
    ii. Validate that the scheduled task has been created via the task scheduler GUI and validate the PowerShell script exists in C:\scripts
  6. When a 8002 error is encountered on the device, ensure that the scheduled task executes and the user can attempt to connect to the network with their new credentials

Screenshots

image

Copy link
Contributor

@jworkmanjc jworkmanjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few items needed work, not sure if it was working when you tested some hello world script but I think (after more than an hour troubleshooting), it didn't execute the script unless the quotes were straight quotes. I'm not postive there.

The remove-wifi script needs a few changes to account for networks with spaces and also there was one missing backtick which broke the script from functioning in the first place.

After making these changes:

  1. signing into a radius network
  2. changing the user's password with the JumpCloud tray app,
  3. clicking "disconnect network"
  4. clicking "connect to network" with the "Remember this Network" option selected
  5. The network failed to connect the first time
  6. The scheduled task ran and then "forgot" the network
  7. I was able to click the network name and enter my new credentials which allowed me to connect to the network.

After addressing the items suggested, task scheduler will report that the script finished with exit code 0
Screenshot 2024-10-15 at 1 28 11 PM

Before fixing any of the items I've suggested, Task Scheduler will report some script finished with this exit code (non-zero)
Screenshot 2024-10-15 at 1 29 39 PM

)
Begin {
`$list = ((netsh.exe wlan show profiles) -match '\s{2,}:\s') -replace '.*:\s' , ''
`$ProfileList = `$List | Foreach-object { [pscustomobject]@{Name = $_ } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing `

Suggested change
`$ProfileList = `$List | Foreach-object { [pscustomobject]@{Name = $_ } }
`$ProfileList = `$List | Foreach-object { [pscustomobject]@{Name = `$_ } }
Screenshot 2024-10-15 at 1 02 09 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this

</Triggers>
<Actions Context="Author">
<Exec>
<Command>“C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe”</Command>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Command>C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe</Command>
<Command>"C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe"</Command>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed these, I didn't have an issue with the XML with the original quotes, but I updated just in case

<Actions Context="Author">
<Exec>
<Command>“C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe”</Command>
<Arguments>-ExecutionPolicy ByPass -File “C:\scripts\removeWifi.ps1”</Arguments>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Arguments>-ExecutionPolicy ByPass -File C:\scripts\removeWifi.ps1</Arguments>
<Arguments>-ExecutionPolicy ByPass -File "C:\scripts\removeWifi.ps1"</Arguments>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not positive but I think the quotes were messing this up initially.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed these, I didn't have an issue with the XML with the original quotes, but I updated just in case

}
} else {
# Save the removeWifi.ps1 file to C:\scripts\removeWifi.ps1
if (!Test-Path -Path C:\scripts) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-10-15 at 12 30 12 PM

Curious if you saw an error here, the first time I ran the script on a device I got this error from the command console

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be potentially better to write If (-Not (Test-Path -Path "C:\scripts")) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise I have no idea why the command result threw that error initially.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was supposed to be (!(Test-Path -Path C:\scripts)), fixed

Copy link
Contributor

@jworkmanjc jworkmanjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works perfect after those changes! @kmaranionjc, since you don't have a radius network to test, here's what I'd expect to see you validate:

  1. Run the script from command console
  2. The script should run successfully on a windows device
  3. The string you specified in the command for the $RadiusSSID variable should be set at the bottom of the script body.

I've validated the network disconnect functionality so if there's an issue it can come back to me but thanks for this Geoff awesome to see us have this as a template, this really cool work.

Copy link
Contributor

@kmaranionjc kmaranionjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work here. Ran successfully on my end.
image

@gweinjc gweinjc merged commit 6b2f83e into master Oct 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants