119,257 questions
3
votes
1
answer
42
views
Powershell Class generic interface arguments type resolution problem
Can't seems to find why generic interface types are allowed in powershell class argument attributes, but they can't accept anything - powershell class type resolution doesn't work in this case. Is ...
4
votes
2
answers
101
views
Can PowerShell automatically create missing directories when redirecting output?
Is there a way to configure PowerShell so that the redirection operator (>) automatically creates any missing parent directories?
For example, the following command fails if c:\missing_dir\ does ...
3
votes
1
answer
79
views
Access VBA for MDW User-Level Security
I have a .accdb front-end, and a .mdb backend.
I am opening the Front-End as a COM object via PowerShell ...
$accessApp = New-Object -ComObject Access.Application
$accessApp.OpenCurrentDatabase($...
Tooling
1
vote
0
replies
39
views
How to block PowerShell execution on Windows 11 multi-session Azure VDI (single local user, others using RemoteApp)
I’m looking for guidance on how to properly block PowerShell execution on a Windows 11 multi-session Azure VDI.
Scenario:
The VM has only one local user who logs in directly to the desktop.
All ...
0
votes
0
answers
54
views
How to get rid of the 'WindowsPowerShell' folder in my 'Documents' folder? [closed]
I recently noticed a WindowsPowerShell folder in my Documents folder. I deleted it, but it comes back after each startup.
Please, could you help me get rid of this folder?
For context, I do not use / ...
-3
votes
1
answer
90
views
How can I list all branches from every repository in a GitHub account using GitHub CLI? [closed]
I'm using GitHub CLI and PowerShell, and I want to list all branches from every repository under a specific GitHub username.
gh repo list only returns the repo names, but I want a way to loop through ...
Advice
1
vote
12
replies
135
views
How can I combine two or more arrays into a unique set without changing the data type in Powershell?
Say I have a combination of the following:
# This is a [string[]] type
$A = [string[]]@("Aasdf","Casdf","Basdfs")
# This is a [string] type
$B = "Dasdfs"
# This ...
-2
votes
0
answers
47
views
Pagefile does not let Windows partition to shrink [closed]
What I'm trying - I'm trying to flash Windows from within Windows. For this, I am trying to create a WinPE and other partitions from within OS to boot into it.
I try to shrink the largest partition to ...
1
vote
0
answers
74
views
Error when running docker compose up command in terminal (Powershell, Windows 11)
I'm following along with this tutorial: https://www.youtube.com/watch?v=PHsC_t0j1dU&t=740s
As shown in the video at timestamp 1:29:09, when the person runs docker compose up in their terminal, ...
0
votes
1
answer
97
views
-Command "dir" with color
In PowerShell, if I do:
dir
I get a listing with color.
However, if I do:
PowerShell -Command "dir"
there is no color.
Is there a way to do PowerShell -Command "dir" and have it ...
Advice
1
vote
2
replies
54
views
How to start new process as another user from PowerShell and use the target user environment?
runas /user:someuser /profile cmd
Starts cmd.exe as someuser and that user's environment. E.g. inside cmd.exe
>echo %USERNAME%
someuser
However, when I am trying to do a similar thing from ...
3
votes
1
answer
98
views
Why does PowerShell stderr redirection mess up unicode characters?
Why does redirecting stderr to stdout, when launching an external program from PowerShell, turn unicode characters into their code point representation? For example:
PS > py -3.13 -c "import ...
0
votes
1
answer
61
views
How to enable shutdown PowerShell script on Windows 2022 without using GUI
I am provisioning Windows 2022 EC2 instances using Terraform and a PowerShell User Data script. I want to add functionality where this User Data script will configure a shutdown PowerShell script ...
1
vote
2
answers
123
views
How can you append to a script block?
I know I can have multiple commands in a script block when the commands are specified at script block creation time:
$sb_both = {
echo 1
echo 2
}
& $sb_both
# returns:
# 1
# 2
But after ...
3
votes
1
answer
115
views
what does assignment to $null do in ($var=$null="...")
I saw in a script this kind of command:
Write-Verbose -Message ($var=$null="foo=$(<some computation>)")
<do something more with $var>
What is the point of assigning the string ...