#Code powershell to switch eSIM to sim on laptop

31 messages · Page 1 of 1 (latest)

frail mauve
#

Hello, I don't know much about powershell but is it possible to make a code to switch from an eSIM to a physical SIM?

sand summit
#

How would you do it without PowerShell? Keep in mind that PowerShell is just a tool.

frail mauve
#

I know I can just do it in the settings, but I'd like to add it to a program I use to prepare laptops, but I can't get the code to work.

edgy yoke
#

Fwiw this was on the main channel.

The question above is pertinent. Doesn't look like it's presenting as a PNP device, but that may also need a "in what operating system" follow-up.

edgy yoke
#

then I'm kind of surprised it's not a PNP device. Start with "How do I do this in the OS"

#

and be aware that MS may not have bothered at all to present a publicly documented programmatic API for it.

frail mauve
#

I don't really understand what you're saying.

edgy yoke
#

if you had to do it in the operating system without scripting it, how would you do it?

frail mauve
#

So I go to settings, then networks and internet, then cellular network and change eSIM to SIM.

edgy yoke
#

hm you might have to watch it with process explorer or something to see if it's making an obvious change to the registry (or similar).

That isn't even an option on my computers so I can't even see what it looks like.

Anything to do with Settings is a bit of a mess though, it might be hard to track down.

frail mauve
#

I search

#

It hard

sinful marsh
#

there are a couple powershell commands capable of altering network settings

#

but without seeing what you are actually changing its hard to guess

frail mauve
#

@sinful marsh

sinful marsh
#

ok, windows 11 ... i have no way to check unfortunately. the only w11 vm i got, has no dropdown in any of its network devices

edgy yoke
#

yeah my win 11 desktop doesn't have any such option, but it has no SIM cards / devices of any kind installed

frail mauve
#

Bruh

edgy yoke
#

the Venn diagram for this one is poor. People who can figure out settings + people who can figure out MSs mess or translate that to powershell + people who have SIM cards in a windows system.

sinful marsh
#

sorry for chatgpt answer:

Got it! If you want to switch between SIM and eSIM profiles using PowerShell, you can use the netsh command to manage network interfaces. Here's a basic example of how you might switch between profiles:

  1. List Network Interfaces: First, list all network interfaces to identify the names of your SIM and eSIM profiles.

    netsh interface show interface
    
  2. Disable Current Profile: Disable the current active profile (SIM or eSIM).

    netsh interface set interface name="YourCurrentProfileName" admin=disable
    
  3. Enable Desired Profile: Enable the desired profile (SIM or eSIM).

    netsh interface set interface name="YourDesiredProfileName" admin=enable
    

Replace "YourCurrentProfileName" and "YourDesiredProfileName" with the actual names of your SIM and eSIM profiles.

This script will disable the current network profile and enable the desired one. Make sure to run PowerShell with administrative privileges to execute these commands.

If you need more advanced control or automation, you might need to look into using the Windows Management Instrumentation (WMI) or other network management tools.

Would you like to explore more about managing network profiles with PowerShell?

#

ive been using netsh for similar stuff in the past. so there may be some truth to this. but its probably not exactly what you are looking for (standard chatgpt disclaimer)

edgy yoke
#

if that works then Get-NetAdapter should show them too

frail mauve
#

Is not work

pliant kite
#

what does get-netadapter return. show that.

#

you can blur the mac if you want

#

the cellular adapter has got to be in the get-netadapter output...i think...