Powershell script Airplane Mode

jesus4gaveme03

New Member
Messages
3
I am writing a script to change my computer settings when I go to work and change them back when I get home.

I would like to know how to script turning on/off Airplane Mode. If that's not possible, how do I script turning on/off wireless and Bluetooth?

Code:
$Office = 'e40fb68e-3e3a-4942-aa68-0490b7e7a790'
$Balanced = '381b4222-f694-41f0-9685-ff5bb260df2e'


$currHour = (get-date).hour


if ($currHour -ge 7 -and $currHour -le 14) {


    powercfg -SetActive $Office
    
    #Disable-NetAdapter -Name "Wi-Fi"


    #Start-Service -displayname "Bluetooth service"
    
    } else {
    
    powercfg -SetActive $Balanced
    
    #Enable-NetAdapter -Name "Wi-Fi"
    
    #Stop-Service -displayname "Bluetooth service"    


    }
 

My Computer

System One

  • OS
    Windows 8

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
You can always script disabling/enabling Wi-Fi and Bluetooth adapters with devcon (64-bit version is also available, but harder to find). So your script will have just a couple of iex lines :)
 

My Computer

System One

  • OS
    Windows 8 Pro x64
    Computer type
    Laptop
    System Manufacturer/Model
    HP Pavilion dv7t (17.3'', i7-2630QM, HD 6770M 1Gb, 8Gb RAM, 2 SSD@120Gb + 1 HDD@750Gb)
I'm not sure I understand your question. devcon.exe is basically a command line version of device manager. You disable Wi-Fi adapter, there's no Wi-Fi, it's that simple.

You can script it with CMD or call it from PS (get-help iex).
 

My Computer

System One

  • OS
    Windows 8 Pro x64
    Computer type
    Laptop
    System Manufacturer/Model
    HP Pavilion dv7t (17.3'', i7-2630QM, HD 6770M 1Gb, 8Gb RAM, 2 SSD@120Gb + 1 HDD@750Gb)
How did you program these apps to start/stop Airplane Mode? If it wasn't powershell, what environment was it?

I used AutoIt with sendkey commands to basically fully automate the keystrokes it would take to do it normally, but in one click now.
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
I used AutoIt with sendkey commands to basically fully automate the keystrokes it would take to do it normally, but in one click now.

Thanks, I will give that a shot, but at this point I think I will use your apps with my PowerShell program.

Do you know how I could make my program run in the background?
 

My Computer

System One

  • OS
    Windows 8
I'm afraid that I'm not experienced enough in PowerShell for that. :(
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
Back
Top