119,067 questions
Score of 3
3 answers
138 views
Invoke-Command not passing variable to target machine
I'm building a powershell script to uninstall a number of outdated apps from remote computers. I retrieved the uninstallstring from the 64bit Uninstall registry key, replaced some wrong characters and ...
Score of 0
0 answers
151 views
Why does local account sometimes not appear in admin group even after being added via PowerShell? [closed]
I run a script on my local PC that executes on a remote PC. This script creates a local account on the remote pc and then adds it to the admin group. Then the remote PC reboots, auto logs in with the ...
Score of 0
3 answers
241 views
Switch / IF Errors [duplicate]
I'm making an onboarding script and currently having issues with this segment of it:
#Switch selector for desired OU of new user (AD)
$OUSelector = $null
Write-Host "OUs: "
$OUSelector = ...
Score of 3
2 answers
232 views
Issue with Powershell function written in $PROFILE path
function gethash {
param([string]$string = '')
if ($string -eq [string]::Empty -or $string -isnot [string])
{
Write-Output 'input not valid'
}
else
{
(Get-FileHash -Algorithm ...
Score of 1
1 answer
187 views
PowerShell Get-Help Test-Path displays incorrect syntax diagrams
On Windows, in PowerShell 7.6.6: Get-Help Test-Path gives me this:
NAME
Test-Path
SYNOPSIS
Determines whether all elements of a path exist.
SYNTAX
Test-Path [-Credential <...
Score of 4
1 answer
132 views
Rename a registry key in Powershell 5.1 that has forward slashes in the key name
I've found this post that explains how to create a new key with a forward slash. That works great if you create new keys, but renaming them doesn't seem to work. Suppose you have this registry key:
...
Score of -3
1 answer
192 views
Unable to remove a junction as normal user on C:\users\some_account (link) [duplicate]
As a normal user (without administrative privileges), I created a junction on C:\users\john.doe\desktop\john.doe pointing on C:\users\john.doe with the command:
New-Item -ItemType junction -path C:\...
Score of 6
3 answers
305 views
Why does PowerShell throw error 1053 instantly when launching powershell.exe as a service?
Editor's note, to clarify why this question is programming-related:
The premise is an existing PowerShell script that aims to implement a Windows service using the appropriate .NET APIs.
However, ...
Score of 1
2 answers
233 views
Print subscript character to console in Java
I'm trying to print a subscript character ("₅") to the console, but it shows as "?" when using System.out.println. What I've tried so far:
Trying the fixSystemOutEncoding() method ...
Score of 0
1 answer
107 views
Get Kerberos TGT expiry time in Powershell
We have some of our more sensitive admin accounts into Protected Users in AD. This has a knock on of preventing the Protected Users from renewing Kerberos TGTs beyond their initial mandated four-hour ...
Score of 6
1 answer
259 views
System.IO.File, one writer, one reader, different computers. shared read open error
I have a script that may run on different computer but must run at most once at a given time. so I wrote a poor-man mutual exclusion based on file locking. Not the best code in the world but it does ...
Score of -4
1 answer
197 views
PowerShell version 7.6.3 (on Windows 11 Pro) Error 'Argument types do not match'
Added 2026-10-12
None of the answers or comments helped with a solution to my issue.
Two comments were correct (Santiago Squarzon on October 1st) and (mclayton on October 11th).
The reason that my ...
Score of 1
1 answer
96 views
PowerShell runspaces duplicated when added to pool
I have a loop that creates runspaces, adds them to $RunspacePool, executes .BeginInvoke() and eventually adds them to an array in a synchronized hashtable.
The script block for each of the runspaces ...
Score of 0
1 answer
172 views
Why is my git command printing errors when doing Start-Job?
I have a very simple script that is supposed to download multiple repos simultaneously. But I am having trouble even getting one working.
$blah = Start-Job {
git clone https://github.com/...
Score of 4
1 answer
135 views
How to infer the class from which a System.Management.Automation.PSMethod object belongs to?
In this example, is there a way to programmatically infer the source object's ("MyTestString") type ? Assume that the source object is a literal and not stored in a variable.
PS C:\> $...