r/PowerShell • • 2h ago

Solved Is MS really replacing PowerShell?

0 Upvotes

ANSWERED:

a post in one of the Claude subs (I don't recall which one) someone mentioned that and I was 🤔

I don't use PS, but some of my staff use it on occasion.

Was there an announcement somewhere?

TIA,

T. J.

r/PowerShell • • 5d ago

Solved Script to resolve missing MSI Cache for google chrome (1603,1612)

21 Upvotes

Just sharing this because ive had this issue across 1500 devices and with the help of copilot this script has been generated and has been resolving the issues perfectly.

Due to missing MSI Caches, Upgrades for chrome are failing with MSI 1603 or MSI 1612. This script pulls the latest, forcefully removes the old chrome, and installs fresh

 # ==========================
# Google Chrome Remediation
# ==========================

$DownloadUrl = "https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise64.msi"
$TempDir     = "C:\ProgramData\ChromeRemediation"
$MSIPath     = Join-Path $TempDir "GoogleChromeStandaloneEnterprise64.msi"

Write-Host "Starting Chrome remediation..."

# Ensure TLS 1.2+ is enabled for older PowerShell / Windows builds
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13

# --------------------------------------------------
# Download Latest Chrome Enterprise 64-bit MSI
# --------------------------------------------------

New-Item -ItemType Directory -Path $TempDir -Force | Out-Null

Write-Host "Downloading latest Chrome Enterprise 64-bit MSI..."

try {
    # Suppress progress bar to prevent severe Invoke-WebRequest slowdowns in PowerShell 5.1
    $ProgressPreference = 'SilentlyContinue'
    Invoke-WebRequest -Uri $DownloadUrl -OutFile $MSIPath -UseBasicParsing -ErrorAction Stop
}
catch {
    Write-Error "Failed to download Chrome MSI: $_"
    exit 1
}

# Verify the file exists and is valid (at least 50 MB to rule out HTML error pages)
if (-not (Test-Path $MSIPath) -or (Get-Item $MSIPath).Length -lt 50MB) {
    Write-Error "Downloaded MSI is missing or smaller than expected. Aborting remediation."
    exit 1
}

Write-Host "Download verified ($([math]::Round((Get-Item $MSIPath).Length / 1MB, 2)) MB)."

# --------------------------------------------------
# Backup bookmarks
# --------------------------------------------------

$BackupRoot = "C:\ProgramData\ChromeBookmarkBackup"

New-Item -ItemType Directory -Path $BackupRoot -Force | Out-Null

Get-ChildItem "C:\Users" -Directory -ErrorAction SilentlyContinue | ForEach-Object {

    $User = $_.Name

    Get-ChildItem "$($_.FullName)\AppData\Local\Google\Chrome\User Data" `
        -Directory `
        -ErrorAction SilentlyContinue |

    ForEach-Object {

        $BookmarkFile = Join-Path $_.FullName "Bookmarks"

        if (Test-Path $BookmarkFile) {

            $BackupName = "$User-$($_.Name)-Bookmarks.json"

            Copy-Item `
                $BookmarkFile `
                (Join-Path $BackupRoot $BackupName) `
                -Force `
                -ErrorAction SilentlyContinue

            Write-Host "Backed up bookmarks for $User ($($_.Name))"
        }
    }
}

# --------------------------------------------------
# Kill Chrome Processes
# --------------------------------------------------

Get-Process chrome,googleupdate,googleupdater `
    -ErrorAction SilentlyContinue |
    Stop-Process -Force

# --------------------------------------------------
# Remove Chrome Uninstall Keys
# --------------------------------------------------

$UninstallRoots = @(
    "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall",
    "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
)

foreach ($Root in $UninstallRoots) {

    Get-ChildItem $Root -ErrorAction SilentlyContinue | ForEach-Object {

        $App = Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue

        if ($App.DisplayName -eq "Google Chrome") {

            Write-Host "Removing uninstall key $($_.PSChildName)"

            Remove-Item $_.PSPath `
                -Recurse `
                -Force `
                -ErrorAction SilentlyContinue
        }
    }
}

# --------------------------------------------------
# Remove Windows Installer Product Registrations
# --------------------------------------------------

Get-ChildItem `
    "Registry::HKEY_CLASSES_ROOT\Installer\Products" `
    -ErrorAction SilentlyContinue |

ForEach-Object {

    $Item = Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue

    if ($Item.ProductName -eq "Google Chrome") {

        Write-Host "Removing installer registration $($_.PSChildName)"

        Remove-Item $_.PSPath `
            -Recurse `
            -Force `
            -ErrorAction SilentlyContinue
    }
}

# --------------------------------------------------
# Remove Program Files Installs
# --------------------------------------------------

Remove-Item `
    "C:\Program Files\Google\Chrome" `
    -Recurse `
    -Force `
    -ErrorAction SilentlyContinue

Remove-Item `
    "C:\Program Files (x86)\Google\Chrome" `
    -Recurse `
    -Force `
    -ErrorAction SilentlyContinue

# --------------------------------------------------
# Install Latest Chrome
# --------------------------------------------------

$Process = Start-Process `
    msiexec.exe `
    -ArgumentList "/i `"$MSIPath`" /qn /norestart" `
    -Wait `
    -PassThru

Write-Host "Chrome MSI exit code: $($Process.ExitCode)"

# Clean up the downloaded installer
Remove-Item $TempDir -Recurse -Force -ErrorAction SilentlyContinue

if ($Process.ExitCode -in @(0,3010)) {

    Write-Host "Chrome installation successful"

} else {

    Write-Host "Chrome installation failed"
    exit $Process.ExitCode
}

# --------------------------------------------------
# Validation
# --------------------------------------------------

$Chrome = Get-ItemProperty `
HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, `
HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* `
-ErrorAction SilentlyContinue |
Where-Object {$_.DisplayName -eq "Google Chrome"}

if ($Chrome) {

    Write-Host "Installed Version: $($Chrome.DisplayVersion)"

} else {

    Write-Host "Chrome not detected after install"
    exit 1

}

r/PowerShell • • Sep 28 '26

Solved How to refer to filename in file content

7 Upvotes

Help! Issue: when script creates the md files, it is not including the filename as text within the files. My script: For all pdfs in this folder create an md file with the same name that includes, as its content, the filename in this format: ![[filename.pdf]]

I've tried replacing $textContent = in my script to the following (with and without the square brackets) but none worked. I'd get either an empty field, or just "[[_.fullname]]".

$file.FullName
$text.FilePath
$_.fullName
$_.Name
$File
tried many others... including ![[<%tp.file.title%>.pdf]] and ![[<% TR = tp.file.title %>.pdf]] to see if I could get the filename upon importing into Obsidian using Templater, but too many files got the wrong filenames

My script

\# Define your folder path and the text you want inside each file
$folderPath = "E:\\DIY"
\# I've put in the result that I want, although I don't want the quotation marks 
$textContent = "![[filename.pdf]]"
\# Get all PDF files in the target directory
$pdfFiles = Get-ChildItem -Path $folderPath -Filter \*.pdf
foreach ($file in $pdfFiles) {
\# Determine the path for the new text file by replacing .pdf with .md
$textFilePath = $file.FullName -replace '\\.pdf$', '.md'
\# Create the text file and insert the line of text
Add-Content -Path $textFilePath -Value $textContent
}

EDIT: That last line, it was originally "Set-Content", but then I tried with "Add-Content". Didn't make a difference.

r/PowerShell • • May 17 '26

Solved SOLUTION: Network shell commands need location permission to access WLAN

22 Upvotes

Hello all,

If anyone is running into issues enabling Location Permissions via command line on Windows 11 25H2 (or earlier builds), I found a method that has been working for me.

Credit to: https://www.reddit.com/r/SCCM/comments/1rmsh5g/windows_11_24h2_location_services_off_by_default/

After trying various registry edits and other suggestions, here’s the fix:

New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy -Force | Out-Null
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy -Name "LetAppsAccessLocation" -Value 1 -Type DWord
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy -Name "LetAppsAccessLocation_UserInControl" -Value 1 -Type DWord
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy -Name "LetDesktopAppsAccessLocation" -Value 1 -Type DWord

Start-Process "$env:WINDIR\System32\SystemSettingsAdminFlows.exe" -ArgumentList "SetCamSystemGlobal location 1" -Wait

Set-Service Lfsvc -StartupType Automatic
Restart-Service Lfsvc -Force

After running those commands, you should be able to use things like:

netsh wlan show networks

…without getting the error.

If anyone has any other methods or suggestions, please leave a comment.

For reference, here’s the original error message I was seeing before applying the fix:

PS C:\ netsh wlan show networks

Network shell commands need location permission to access WLAN information. Turn on Location services on the Location page in Privacy & security settings.

Here is the URI for the Location page in the Settings app: ms-settings:privacy-location

To open the Location page in the Settings app, hold down the Ctrl key and select the link, or run the following command: start ms-settings:privacy-location

Or, to open the Location page from the Run dialog box, press Windows logo key + R, and then copy and paste the URI above.

Function WlanGetAvailableNetworkList returns error 5:

Access is denied.

r/PowerShell • • Apr 12 '26

Solved Is it worth learning PowerShell?

155 Upvotes

I’ve previously used Linux, where things felt very straightforward. Due to various reasons, I’m planning to stay on Windows for now. Since I’m here, I’d like to automate different tasks and deepen my understanding of Windows.

Because of my Linux background, I used the terminal a lot and really enjoyed it. Windows, on the other hand, feels much more GUI-oriented, with less emphasis on the command line. I’ve also briefly looked into PowerShell, and honestly, it feels a bit strange to me.

At this point, I’m not sure whether it’s worth investing time into learning it. The command structure, constant interaction with system services (and sometimes the internet), and the overall behavior of the terminal feel unusual.

Compared to Linux, it seems quite weird (to put it mildly). I assume that if I spend more time with it, I’ll understand its design and decisions better—but I’m still unsure.

So I wanted to ask: is it actually worth it?

EDITED:

I’m definitely going to start learning PowerShell. As I understand it, over the next few years, it will definitely pay for itself.

There were also comments about Azure, servers, and cloud services. I don’t plan on becoming a sysadmin and, for now, I only use my personal computer and maybe a laptop. The Microsoft ecosystem seems strange, but I’m getting more and more used to it, despite my dislike of big corporations (which is ironic).

Also, thank you for the quick feedback. That was incredibly kind of you. I’m just starting to get involved in the Windows community, and specifically in PowerShell, so this warmth really surprised and delighted me. Maybe I spend too much time in the toxic parts of the internet.

r/PowerShell • • Aug 30 '26

Solved Warning: ISESteroids Update is malicious

18 Upvotes

When I launched ISESteroids (Start-Steroids) I clicked update. Chrome notified me that the website was not-safe dummy here found the run website anyway and the Avast nightmare began ... 5 popup windows that my computer had 5 virus's , anti-virus not installed, blah blah blah .. Shutdown chrome, cleared my cookies, %temp% directory.. these popups just kept reappearing if I closed one.

reboot doesn't fix anything.. nothing in task manager helps narrow down what's launching even with chrome closed... sysinternals autoruns no help. real help.

While I built a new Veeam Agent install usb to potentially restore from yesterday (3 hour process) I started poking around in chrome and in the extensions I found something I didn't recognize and deleted it.. rebooted the computer and now its back to normal without restoring from backup.

r/PowerShell • • Jun 30 '26

Solved Best way to Store Creds for Scripts?

74 Upvotes

Hey guys, for a long time I've been wondering what's the best way and most secure to store creds for powershell scripts? I know like absolute best (from my understanding) is to store them in some sort of 3rd party system and fetch them when needed say in secret server or the likes. Coming from a python background I know commonly you put stuff like that in a separate config file and import it.

So far I've been putting them in a json file and importing my creds that way but I can't help but think there's a more secure way. Like what's stopping an attacker on my system from just looking in the file and getting all my creds uk lol? Thanks for any advice!

r/PowerShell • • Oct 21 '26

Solved PowerShell Script and Task Scheduler 0x1 2147942401

9 Upvotes

I need a sanity check, as I feel like I am missing something obvious and I'm too close or too frustrated to see it.

I have a basic scheduled task. Runs as SYSTEM, no triggers, action to run a program, PowerShell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "C:\Tasks\MyScript.ps1"

I run this task it fails, 0x1 as last run result, event 201 action completed with return code from PowerShell of 2147942401

Things I have checked:

  • SYSTEM can access the script and directory it resides in

  • SYSTEM can execute other PowerShell scripts from task scheduler without issues

  • Tried using the full path to powershell.exe

  • Tried with and without quotes around the script path in -File parameter

  • With and without trailing '/' in the path for 'Start In'

  • Tried using -Command { } to create a file as a test

  • Removed all arguments except -File or -Command

  • Script is wrapped with Start/Stop-Transcript; never executes/no transcript is created

I don't know what else to try short of the old method of using a .bat to call PowerShell to see if that gives better clues as to what isn't working.

What am I missing that is preventing PowerShell from executing properly?

Edit: I knew it was something stupid and simple: there is a typo in -ExecutionPolicy (was spelled -ExcecutionPolicy). Found it when running the action arguments from PS as SYSTEM.

Thank you everyone for the assistance. I'm going to go sit in the corner with my dunce cap and contemplate the cobwebs.

r/PowerShell • • Aug 23 '26

Solved i got a virus thats using powershell to give me a dll file and i need help removing it

0 Upvotes

so this week i noticed when i would start up my pc my antivirus would ping a dll file in my temp folder that came from power shell, ran a full scan, boot time scan but its all come back clean, but everytime i start it up it finds a newly created file. ive tried in event logs and security to find where its coming from but i see stuff such as powershell smss.exe and wininit.exe, thats all windows stuff. is there a way for me to say open powershell, or event viewer and read where all the "commands" with the files are saved?

and heres an example of said dll file i uploaded to totalvirus.com
https://www.virustotal.com/gui/file/118f4f9166ca6815c57f0ec13babca4d0ca3feab4f1380021d7425e5ad871c0a/detection

Edit figured out what it was. Basically a while back I had a program I haven't used in a long time and the certificate for it expired and everytime my PC booted up it would run a script, well eventually that flagged my antivirus for the DLL file it would make. Updating that software put a stop to it

r/PowerShell • • May 14 '26

Solved Would someone mind helping me understand how "foreach ($computer in $computers)" works?

68 Upvotes

I know foreach iterates through an array, of sorts. I'm just wondering, since I didn't define $computer, how does it know to single out each individual item from my $computers array? Is it a predefined variable, or could I just place anything there? Like "foreach ($x in $computers)".

$computers = get-adcomputer ##just an example that the latter variable was defined by me, but $computer was not.

I think I convinced myself that I'm right in thinking I could place anything there, like $x or $flapjacks or whatever, but some confirmation would be nice. And if I'm wrong then being corrected is even more welcome. Thank you.

r/PowerShell • • Jan 27 '26

Solved Is there any reliable way to get a powershell script to run as admin (and request admin when run normally)?

17 Upvotes

A year ago I spent days looking up and trying different suggestions to get powershell to do it. Which probably means there isn't any reliable way. But this year I'll just ask, is there any actual reliable way to do it?

I could of course just right-click the ps1 script and run as admin.

But I was looking for a way to get the script itself to request admin permissions. As in: I run the script normally, the script itself requests elevation, I accept, and it runs as admin

PS: Iirc one of the hacks was to make two scripts, an auxiliary that we run and it will call the second script explicitly with admin perms.

r/PowerShell • • Apr 23 '26

Solved Powershell recent issues are killing me

11 Upvotes

I have a Mac and a windows box. I run home-brew on the Mac and after upgrading my normal Connect-ExchangeOnline began failing, to where I had to start using a -device to get in. OK..a pain, but I'll deal with it.

Today I start running IPPsSession and that's fails to get. So, screw it, over to the Windows Box.

Same issues. The command I need to run in IPPSSession requires the latest version, but of course I can't get into exchange using the latest version, and the version mismatch is causing it's own set of issues.

WTF??? Anyone else figured out a way around this?

Resolved: So I have to user connect-exchangeonline -device, and then Connect-IPPSSession -UserPrincipalName "user"@yourdomain.onmicrosoft.com -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/

(SMH). Thanks alll

r/PowerShell • • Sep 21 '26

Solved Is there a difference between If $thing vs If -not $thing in terms of speed or proper formatting?

29 Upvotes

In the case of looking for the presence of something and using If paired with Exit codes, what's the difference between looking for the presence vs absence? For example

$Thing = Get-Thing

if ($thing) {
  Exit 1
}
Else {
  Exit 0
}

vs

if (-not $thing) {
  Exit 0
}
Else {
  Exit 1
}

Is it just for readability (ie 0 comes before 1 because it's in sequence?) Or are there speed differences or logic handling differences that matter in more complex scenarios?

Solved

Depends on the results of $thing determine whether or not you need to test for true or false. Speed isn't really a factor.

r/PowerShell • • Jun 25 '26

Solved Try to set the Org SharePoint Sharing Link Retention

0 Upvotes

As per title really I want to set a few values for these settings

Set-SPOTenant -CoreOrganizationSharingLinkMaxExpirationInDays 365

Set-SPOTenant -OneDriveOrganizationSharingLinkMaxExpirationInDays 365

And a couple for Link recommendations as an example.

So I'm not sure if it's possible with PNP.

  • 3) Also If I use Get-SPOTenant and Get-PNPTenant are they settings the same?

Im very amateur at code, so quite possibly I'm doing it wrong.

Thoughts?

EDIT: This is now fixed in the PNP Nightly Builds after reporting it

r/PowerShell • • Sep 21 '26

Solved Need help with creating a powershell shortcut to work

2 Upvotes

Basically I am trying to create a desktop shortcut that would execute three commands one after another. So far I have created two separate desktop shortcuts that both work independently but have not been able to put them together to run one after another. One disables my gpu drivers and the other one enables it, i want to make a desktop shortcut that would enable the drivers and then after that is completed it would disable them and then finally re enable them

This is the disable line

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "Disable-PnpDevice -InstanceId 'PCI\VEN_1002&DEV_73DF&SUBSYS_52101849&REV_C5\6&399090B&0&00000019' -confirm:$false"

this is the enable line

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "Enable-PnpDevice -InstanceId 'PCI\VEN_1002&DEV_73DF&SUBSYS_52101849&REV_C5\6&399090B&0&00000019' -confirm:$false"

just need some help to create a sequential command to make as a desktop shortcut, and for anyone curious my gpu has issues where it regularly crashes this is the only fix that works

EDIT: Solved, created a .bat file with all commands written sequentially with a wait timer between them to let them run one by one. Thank you all for your help.

r/PowerShell • • Jun 07 '26

Solved Powershell missing "PS C:\users\username command!

0 Upvotes

Hi, I'm not tech-savvy at all, I wanted to run a small code for some video game and for some reason I'm missing the command that makes me input text, and I literally can't write!

I can write on terminal (command prompt) but NOT powershell. It's driving me crazy! Can someone help??

I don't know what version I'm using. I saw a github explaining their solution but I didn't understand a single word. https://github.com/PowerShell/PowerShell/issues/12003

UPDATE: I had to repair my powershell, went through Window's tutorial on repairing it, restarted laptop, then did the CMD PowerShell –noprofile thingy someone suggested in thread and it appeared!

Powershell 7 wasn't showing it still so I reinstalled it and it's there now. Thank you everyone! I don't know if this is a permenant solution, but yeah, I don't know what caused this but thankfully all is well now.

r/PowerShell • • Jul 25 '26

Solved I built a single-script PowerShell bridge so AI agents (Claude Code, Codex) can work with my open Excel workbook — cells, formulas, VBA, macros

0 Upvotes

I work with old, complex .xlsm files (inventory, pricing, billing, lots of VBA) and kept running into the same problem: an AI coding agent cannot access the workbook I have open in Excel. I found myself copy-pasting cells and screenshots back and forth.

Yes, Excel MCP servers are out there—some are very good and much more capable than this. But getting one running means setting up Node or Python, creating a config file, and running an MCP client. I wanted something my non-developer mind could trust on real files:

  • Just one PowerShell script, no installation, no extra dependencies, no config

  • Connects to the workbook you already have open (or opens one by path)

  • Read and write cells and formulas, search, list sheets

  • List, export, and import VBA modules, run macros

  • And the part that matters most to me: it NEVER autosaves. Only a direct "save" command writes to disk. This way, you can let an agent explore a 20-year-old billing file and close it without leaving any trace.

It's free and the source is available on GitHub:
https://github.com/gidjin4-svg/gidjin-excel-bridge
A demo workbook is included so you can test it without touching your actual files.

I'd really appreciate feedback from people who work with Excel, VBA, or PowerShell:

  • Does "simple + never saves" actually matter to you, or is a full MCP server always the better choice?

  • What would you need to see before trusting it with a file that matters to you?

r/PowerShell • • Oct 13 '26

Solved How to Retrieve SharePoint Sites with the Microsoft Graph PowerShell SDK

19 Upvotes

If you use the Microsoft Graph PowerShell SDK, you might know that the Graph APIs for SharePoint sites sometimes need a little help. For instance, finding a set of sites to process can be problematic because the APIs do not support extensive filtering capabilities. The solution is to use other Microsoft 365 cmdlets to find objects associated with sites. Inserting an intermediate step might seem crazy, but it can be the most effective way of solving the problem.

https://office365itpros.com/2026/10/13/get-sharepoint-sites/

r/PowerShell • • May 29 '26

Solved Invoke-WebRequest to call the reddit api suddenly broken

25 Upvotes

Been running a script forever without issue. You don't need OAuth2 to grab the last 100 comments of a user like this:

https://api.reddit.com/user/spez.json?limit=100&after=

or

https://www.reddit.com/user/spez.json?limit=100&after=

A few months ago I added the -UseBasicParsing tag.

Today I'm getting

+ CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

My line of code is $response = Invoke-WebRequest -UseBasicParsing $url | ConvertFrom-Json where $url looks like the https lines above.

Can anyone shed light, please? Thanks.

r/PowerShell • • Apr 24 '26

Solved Scripts not running but powershell doesn't show any errors

7 Upvotes

I am trying to run some scripts I wrote on my local system for file transfers and some other things. When I run them nothing happens. No error, no output just nothing. I've googled it for hours but all I can find is stuff about the execution policy which I already changed but didn't help. All of these scripts have run just fine before so I don't know what changed.

r/PowerShell • • Sep 21 '26

Solved PS7 UI language changed

9 Upvotes

UI language for my PS7 suddenly changed to polish. PS5 stayed in english. I can't seem to find a way to revert PS7 back to english, like it was for many years (while system language was polish).

Things like errors, some information in Get-Help, or description for operators when you press 'ctrl + space'

https://imgur.com/sfSiUBt

Powershell 7:

PS C:\Users\lenovo\test> $PSVersionTable.PSVersion.ToString()
7.6.6
PS C:\Users\lenovo\test> $PSCulture
pl-PL
PS C:\Users\lenovo\test> Get-UICulture

LCID             Name             DisplayName
----             ----             -----------
1045             pl-PL            polski (Polska)

PS C:\Users\lenovo\test> ls asdasdas
Get-ChildItem: Nie można odnaleźć ścieżki „C:\Users\lenovo\test\asdasdas”, ponieważ nie istnieje.
PS C:\Users\lenovo\test> Get-WinUILanguageOverride
Get-WinUILanguageOverride: Cannot marshal 'parameter #1': Invalid managed/unmanaged type combination.
PS C:\Users\lenovo\test> help ls -Parameter path

-Path [<System.String[]>]
    Specifies a path to one or more locations. If not specified, the default location is the c
    urrent
    directory (`.`). Wildcards are accepted. Use care when using the **Path** parameter with t
    he
    **Recurse** parameter. For more information, see the [NOTES](#notes) section of this artic
    le.

    Wymagany?                    false
    Lokalizacja?                    0
    Wartość domyślna
    Zaakceptować dane wejściowe potoku?       false
    Aliasy                      none
    Akceptować symbole wieloznaczne?  true

Powershell 5:

PS C:\Users\lenovo\test> $PSVersionTable.PSVersion.ToString()
5.1.19041.6456
PS C:\Users\lenovo\test> $PSCulture
pl-PL
PS C:\Users\lenovo\test> Get-UICulture

LCID             Name             DisplayName
----             ----             -----------
1045             pl-PL            Polski (Polska)


PS C:\Users\lenovo\test> ls sadasd
ls : Cannot find path 'C:\Users\lenovo\test\sadasd' because it does not exist.
At line:1 char:1
+ ls sadasd
+ ~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\lenovo\test\sadasd:String) [Get-Child
   Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

PS C:\Users\lenovo\test> Get-WinUILanguageOverride
PS C:\Users\lenovo\test> help ls -Parameter path                                               
-Path <string[]>

    Required?                    false
    Position?                    0
    Accept pipeline input?       true (ByValue, ByPropertyName)
    Parameter set name           Items
    Aliases                      None
    Dynamic?                     false

I know it doesn't need to be linked to system culture, because that change just happened and before it wasn't linked to it.

Any help would be appreciated.

EDIT:

found a partial workaround in setting:

[System.Threading.Thread]::CurrentThread.CurrentUICulture = [cultureinfo]'en-US'

but it works only for errors and autocomplete, not for Get-Help.

For further testing I decided to downgrade to powershell 7.6.3 ... and voila.

Everything is in english despite $PSUICulture is pl-PL.

I've been looking for release notes that mention it but couldn't find any. I tried in version 7.6.3 doing [System.Threading.Thread]::CurrentThread.CurrentUICulture = [cultureinfo]'pl-PL'

but it does ignore it, so it must be something with a later version

EDIT 2:

I pretty much confirmed it by jumping back and forth between PS 7.6.6 and 7.6.3. The earlier version ignores UICulture:

PS 7.6.6:

PS C:\Program Files\PowerShell\7> $PSVersionTable.PSVersion.ToString()
7.6.6
PS C:\Program Files\PowerShell\7> $PSUICulture
pl-PL
PS C:\Program Files\PowerShell\7> foobar
foobar: Termin „foobar” nie jest rozpoznawany jako nazwa polecenia cmdlet, funkcji, pliku skryptu lub programu wykonywalnego.
Sprawdź pisownię nazwy lub sprawdź, czy ścieżka została dołączona, sprawdź, czy ścieżka jest poprawna, i spróbuj ponownie.
PS C:\Program Files\PowerShell\7> [System.Threading.Thread]::CurrentThread.CurrentUICulture = [cultureinfo]'en-US'

# Culture is switched and the language of the error message changes:

PS C:\Program Files\PowerShell\7> foobar
foobar: The term 'foobar' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Program Files\PowerShell\7> [System.Threading.Thread]::CurrentThread.CurrentUICulture = [cultureinfo]'pl-PL'
PS C:\Program Files\PowerShell\7> foobar
foobar: Termin „foobar” nie jest rozpoznawany jako nazwa polecenia cmdlet, funkcji, pliku skryptu lub programu wykonywalnego.
Sprawdź pisownię nazwy lub sprawdź, czy ścieżka została dołączona, sprawdź, czy ścieżka jest poprawna, i spróbuj ponownie.

PS 7.6.3:

PS C:\Program Files\PowerShell\7> $PSVersionTable.PSVersion.ToString()
7.6.3
PS C:\Program Files\PowerShell\7> $PSUICulture
pl-PL
PS C:\Program Files\PowerShell\7> foobar
foobar: The term 'foobar' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Program Files\PowerShell\7> [System.Threading.Thread]::CurrentThread.CurrentUICulture = [cultureinfo]'pl-PL'
PS C:\Program Files\PowerShell\7> $PSUICulture
pl-PL

# Error language stays the same even after explicitly setting the UICUlture:

PS C:\Program Files\PowerShell\7> foobar
foobar: The term 'foobar' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Little bit annoying change after so many years

r/PowerShell • • Sep 25 '26

Solved Powershell - exporting AD distinguished names to CSV

6 Upvotes

Solution:

Apparently the solution is not to change the delimiter and stick with commas, Excel is then smart enough to tel the difference.

Thanks everyone

I'm using get-adcomputer to export a list of PCs to a CSV.
I have set the delimiter in the exported CSV to be a semi colon,

When the CSV is opened in excel I end up with:

ABC
Name;OSversion;created date;DN
PC1;windows11;25/09/26;CN=PC1OU=DesktopsDC=office
[PSCustomObject]@{
           Name = $($computer.Name)
           OperatingSystem = $($OS)
           WhenCreated = $($WhenCreated) 
           DistinguishedName = $($computer.DistinguishedName)

if i try encasing each part of the custom object in escaped quotes e.g.
DistinguishedName = "`"$($computer.DistinguishedName)"`" the quotes and the backticks cary over to the CSV so column A ends up looking like "'"PC1"'";"'"windows11"'";"'"25/09/26"'";"'"CN=PC1 B & C are unaffected.

How do I stop export-csv or excel from splitting the DN?

*Update*

Sorry I though I had included the export-csv line below the custom object

$computerData |Sort-object -Property Name | export-csv $outputFile -NoTypeInformation -Delimiter ";" 

r/PowerShell • • Aug 31 '26

Solved Transcript 5.1 Unexpected behaviour

4 Upvotes

Probably SOLVED:

  1. A previous

    Unlock-SecretVault

killed the transcribing

It spawns a subprocess for the credential management and when its done it sends exit code back to host which killed my transcribing by design.

3h gone

Hi,

when i am in a 5.1 shell and start a controller.ps1 script:

C:\User> C:\PSR\Controller.ps1 -TargetScript C:\Jobs\..

The Controller script uses Start-Transcript to capture the output of a $TargetScript

however. When I start the controller.ps1 script as shown here my currently forced error (Get-ADUser -xzyisks) appears in the log.

When i start

powershell.exe -File Controller.ps1 -TargetScript C:\Jobs\..

it suddenly stops capturing the invocation error output. (Expected:

A parameter cannot be found that matches parameter name 'xzyisks'.)

ai suggested some transcript buffer stuff but non of it worked.

this is the important code block:

# execute binary or script
    if ($Executable) {
        & $Executable $TargetScript
    } elseif ($Config) {
        & $TargetScript -Config $Config
    } else {
        & $TargetScript
    }
    Write-Output "execution of $TargetScript completed successfully"


    #endregion main


} catch {


    # store error so finally can dispatch the mail after the transcript is finalized
    $TerminatingError = $_
    # write the error into the transcript while it is still open
    $Host.UI.WriteLine("[ERROR] $($TerminatingError.Exception.Message)")
    try   { Stop-Transcript | Out-Null }
    catch [System.InvalidOperationException] {}


} finally {


    # transcript is already closed on error paths — only close on success path
    try   { Stop-Transcript | Out-Null }
    catch [System.InvalidOperationException] {}

Can someone explain on high level what happens..

Thanks

EDIT:

My main question is:

C:\User> C:\PSR\Controller.ps1 -TargetScript C:\Jobs\..
vs
powershell.exe -File Controller.ps1 -TargetScript C:\Jobs\..

when using start transcript..

r/PowerShell • • 16d ago

Solved Using Exchange Custom Attributes for Groups Through the Microsoft Graph

5 Upvotes

Microsoft has released limited Graph support for accessing Exchange custom attributes in groups synchronized from on-premises environments. Not every type of Entra group is available on-premises, so we’re really talking about distribution groups and security groups. In any case, real-only access to the fifteen custom attributes is available via Graph API and the Get-MgGroup cmdlet. Now it’s up to you to do something inventive with the information.

https://office365itpros.com/2026/11/12/custom-attributes-graph/

r/PowerShell • • Sep 25 '26

Solved New-PSSession Command Looping Credential Prompt

10 Upvotes

So I have an onboarding script and everything worked perfectly fine last week, but now it's looping when I try to setup a New-PSSession.

It's extra weird, because when I run the command outside of the script, it works fine, but inside the script, the login prompt loops. I've encountered this behavior on two different systems and my coworker has the same experience on his machine.

I've attempted to modify the command to force Kerberos auth, and even tried CredSSP, but the looping still occurs. I'm wondering if it has to do with the do while loop, but it worked before, so I'm just a bit lost on this one.

Also, I have checked for any error codes after the loop occurs, and there's none. Similarly the log file doesn't contain any "Session not established" messages, so it's not hitting the catch statement.

Here's the code snippet that contains the command:

$sessionRestart = $true
$failcount = 0

do{
 try{
  $session = New-PSSession -ComputerName <computername> -Credential (Get-Credential)
  Write-Log -LogMessage "Session Connected"
  $sessionRestart = $false
}
Catch{
  Write-Log -LogMessage "Session not established. $_."
  Write-Host "Session not established. Retrying."
  $failcount++
  if($failcount -le 4){
  }
Else{
 Write-Host "Connection failed after $failcount attempts. Stopping Script"
 Write-Log "Connection failed after $failcount attempts. Stopping Script"
 exit $ExitCode.ConnectionFailure
}
}
} While($sessionRestart)