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: fix radius wifi network commands.json #615

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $RadiusSSID = ''
$Overwrite = $false


#### DO NOT EDIT BELOW THIS LINE ####
# DO NOT EDIT BELOW THIS LINE #
$removeWifips1 = @"
function Get-WifiProfile {
[cmdletbinding()]
Expand Down
2 changes: 1 addition & 1 deletion PowerShell/JumpCloud Commands Gallery/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
{
"name": "Windows - Forget RADIUS WiFi Network | v1.0 JCCG",
"type": "windows",
"command": "# Enter the SSID of the Radius network\n$RadiusSSID = ''\n\n# Change Overwrite to $true if you would like to re-create existing Scheduled Tasks\n# This should only be used if redistributing this command to devices\n$Overwrite = $false",
"command": "# Enter the SSID of the Radius network\n$RadiusSSID = ''\n\n# Change Overwrite to $true if you would like to re-create existing Scheduled Tasks\n# This should only be used if redistributing this command to devices\n$Overwrite = $false\n\n\n# DO NOT EDIT BELOW THIS LINE #\n$removeWifips1 = @\"\nfunction Get-WifiProfile {\n [cmdletbinding()]\n param\n (\n [System.Array]`$Name = `$NULL\n )\n Begin {\n `$list = ((netsh.exe wlan show profiles) -match '\\s{2,}:\\s') -replace '.*:\\s' , ''\n `$ProfileList = `$List | Foreach-object { [pscustomobject]@{Name = `$_ } }\n }\n Process {\n Foreach (`$WLANProfile in `$Name) {\n `$ProfileList | Where-Object { `$_.Name -match `$WLANProfile }\n }\n\n }\n End {\n If (`$Name -eq `$NULL) {\n `$Profilelist\n }\n }\n}\nfunction Remove-WifiProfile {\n [cmdletbinding()]\n param\n (\n [System.Array]`$Name = `$NULL\n )\n begin {}\n process {\n Foreach (`$item in `$Name) {\n `$Result = (netsh.exe wlan delete profile `$item)\n If (`$Result -match 'deleted') {\n \"WifiProfile : `$Item Deleted\"\n } else {\n \"WifiProfile : `$Item NotFound\"\n }\n }\n }\n}\n\nRemove-WifiProfile \"$($RadiusSSID)\"\n\"@\nfunction Distribute-JCScheduledTask {\n param (\n [boolean]$Overwrite\n )\n # Get Current User for JC Commmand\n $CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name\n\n # Scheduled Task XML Configuration\n $ScheduledTaskXML = @\"\n<?xml version=\"1.0\" encoding=\"UTF-16\"?>\n<Task version=\"1.2\" xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n <Settings>\n <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>\n <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>\n <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>\n <IdleSettings>\n <StopOnIdleEnd>true</StopOnIdleEnd>\n <RestartOnIdle>false</RestartOnIdle>\n </IdleSettings>\n </Settings>\n <Triggers>\n <EventTrigger>\n <Subscription>&lt;QueryList&gt;&lt;Query Id=\"0\" Path=\"Microsoft-Windows-WLAN-AutoConfig/Operational\"&gt;&lt;Select Path=\"Microsoft-Windows-WLAN-AutoConfig/Operational\"&gt;*[System[Provider[@Name='Microsoft-Windows-WLAN-AutoConfig'] and Task = 24010 and (EventID=8002)]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>\n </EventTrigger>\n </Triggers>\n <Actions Context=\"Author\">\n <Exec>\n <Command>\"C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe\"</Command>\n <Arguments>-ExecutionPolicy ByPass -File \"C:\\scripts\\removeWifi.ps1\"</Arguments>\n </Exec>\n </Actions>\n</Task>\n\"@\n # Check if the scheduled task exists, skip unless Overwrite is specified\n $scheduledTask = Get-ScheduledTask -TaskName \"JumpCloud - Remove WiFi Failure\" -ErrorAction SilentlyContinue\n if ($scheduledTask) {\n Write-Output \"[status] JumpCloud - Remove WiFi Failure scheduled task already exists\"\n if ($Overwrite) {\n # Save the removeWifi.ps1 file to C:\\scripts\\removeWifi.ps1\n if (!(Test-Path -Path C:\\scripts)) {\n New-Item -Path \"C:\\\" -Name \"scripts\" -ItemType \"directory\"\n }\n $removeWifips1 | Out-File -FilePath C:\\scripts\\removeWifi.ps1 -force\n # Overwrite specified, unregister existing task and recreate\n Unregister-ScheduledTask -TaskPath '\\JumpCloud RADIUS\\' -TaskName 'JumpCloud - Remove Wifi Failure' -Confirm:$false\n Write-Output \"[status] Removed existing 'JumpCloud - Remove WiFi Failure' Scheduled Task\"\n Register-ScheduledTask -xml $ScheduledTaskXML -TaskName \"JumpCloud - Remove WiFi Failure\" -TaskPath \"\\JumpCloud RADIUS\\\" -User $CurrentUser \u2013Force\n Write-Output \"[status] Distributed 'JumpCloud - Remove WiFi Failure' Scheduled Task\"\n }\n } else {\n # Save the removeWifi.ps1 file to C:\\scripts\\removeWifi.ps1\n if (!(Test-Path -Path C:\\scripts)) {\n New-Item -Path \"C:\\\" -Name \"scripts\" -ItemType \"directory\"\n }\n $removeWifips1 | Out-File -FilePath C:\\scripts\\removeWifi.ps1\n # Create the Scheduled Task\n Register-ScheduledTask -xml $ScheduledTaskXML -TaskName \"JumpCloud - Remove WiFi Failure\" -TaskPath \"\\JumpCloud RADIUS\\\" -User $CurrentUser \u2013Force\n Write-Output \"[status] Distributed 'JumpCloud - Remove WiFi Failure' Scheduled Task\"\n }\n}\nDistribute-JCScheduledTask -Overwrite $Overwrite",
"link": "https://github.com/TheJumpCloud/support/blob/master/PowerShell/JumpCloud%20Commands%20Gallery/Windows%20Commands/Windows%20-%20Forget%20RADIUS%20WiFi%20Network.md",
"description": "The purpose of this script is to resolve an issue when a user changes their JumpCloud password after connecting to a JumpCloud backed Radius network they will never be able to connect unless they forget the existing network.\n\nIn order to accomplish this, the command will create a scheduled task on the workstation that looks for 8002 errors when attempting to connect to the specified Radius SSID. If an error is detected, a PowerShell script will be initiated that will forget the network for the user which will allow them to attempt to connect again and prompt for their updated credentials"
},
Expand Down
Loading