All Questions
Tagged with windows powershell
1,583
questions
1
vote
1
answer
26
views
Terminal Powershell differences
When I type dir /A into terminal I get desirable output, but when I type the same to Powershell i get
dir : Cannot find path 'C:\A' because it does not exist.
+ CategoryInfo : ObjectNotFound: ...
0
votes
1
answer
58
views
How to solve a final pb when merging a series of .ts file with concat command of FFmpeg?
I had dowloaded some videos from the Internet, feaw years ago…
I obtained many files: a series of files in .ts
In my example: a series of 306 files named from segment1_4_av.ts to segment306_4_av.ts
A ...
0
votes
1
answer
38
views
I can't insert long paths in the "Target" box in Windows 11 shortcut properties (might consider using vbs or batch)
I'm trying to create a Windows shortcut that will be put in my startup folder. The shortcut starts a program (Discord), but with a 1-minute delay. I'm doing this because my (ancient) core i3-2100 PC ...
0
votes
1
answer
30
views
Getting the Display Version of the current computer with Powershell7 (I.E.: 22H2). But ReleaseId conflicts with DisplayVersion
I've read a bunch of threads on here about this and I want to get the Windows edition (22H2 for instance).
This is the code:
$ReleaseID = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\...
0
votes
0
answers
28
views
How to mimic Windows Security UI rights via Powershell
I have a folder that contains bunch of *.exe and *.dll files (not necessarily all in root) and I want to Forbid Write to {S-1-1-0} (Everyone) on all these files.
I've tried:
Get-ChildItem -Path c:\my\...
0
votes
1
answer
31
views
Windows Terminal, Command Prompt, and PowerShell cannot change directory to or start in a folder with Asian characters
I'm on Windows 10.
I have this problem where I'm unable to start the terminal (which I set up to start with Powershell), or changing directory to this folder:
D:\Scanlation\神作家・紫式部のありえない日々\Upscaled\[...
0
votes
1
answer
38
views
Run script elevated as different user on remote machine
I have a Windows Scheduled Task that runs a Powershell script file A.ps1. This task runs mostly locally and does NOT need elevation/administrator access. However, a few steps need to run on a remote ...
0
votes
1
answer
51
views
Cannot delete file in Windows 10 [duplicate]
On Windows 10, there is a file [%UserProfile%\Videos\Lorem.mkv] that is less thant 9KB and I cannot delete it. The file belongs to me, I have permissions to it, there are no prompts for entering a ...
2
votes
1
answer
74
views
Powershell script to show drive health only for drives with a drive letter
I'm made a powershell command that will give me info about physical drive health, in the following format:
DeviceId : 0
FriendlyName : WDC WD84PURZ-85B2YY0
OperationalStatus : OK
...
0
votes
0
answers
61
views
How to suspend Windows PC for a specified period of time using Powershell?
Using Powershell or batch scripts, how to make a PC with Windows OS automatically suspend during the weekdays and automatically reactivate for every weekend?
I know that in Linux OS this can be ...
2
votes
1
answer
56
views
Trying to capture same functionality in Windows cmd prompts as in a PowerShell list of commands using net localgroup
I work in an environment with a mix of older and newer Windows components on isolated networks. To try and make a certain task easier, I worked on a list of PowerShell commands to create a single text ...
0
votes
0
answers
23
views
Starting a program from the CLI with some File Properties Options activated
Start a program from the CLI with some File Properties Options activated
I want to start from the CLI automatically a graphical application with a File properties flag setted.
High DPI scalling ...
0
votes
2
answers
46
views
How can I have a colored Powershell prompt and still have conda env label?
When I add the code below to C:\Users\USERFOLDER\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:
function prompt
{
$ESC = [char]27
"$ESC[46mPS $($executionContext.SessionState....
0
votes
1
answer
48
views
Is this OEM section in an .inf driver file a bug?
I can't seem to find the driver name. Instead of specifying the name, this .inf seems to specify;
[Manufacturer]
%OEM%=OEM,NTx86,NTamd64
[OEM.NTx86]
%PRINTER1%=INSTALL_SECTION,USBPRINT\...
0
votes
2
answers
227
views
Reset Windows Update settings back to default, including respective local policy, by command-line only?
I have many Windows 10 and Windows 11 machines, which are in different states of windows update settings. Unfortunately, some machines have local policies active for windows update settings.
I need to ...
1
vote
1
answer
83
views
Windows 11 Task Scheduler - How to stop a running powershell script task?
In Task Scheduler, how may I stop a running task sooner than 1 hour, say immediately after execution?
I've tried manually entering '1 minute', but the Task is still 'running'. Suggestions?
I'm running ...
2
votes
0
answers
57
views
How to Get Console Font Size from Script?
I opened PowerShell console window, then checked the font size in properties is 16.
How do I get that via script?
I looking for $Host.UI.RawUI not in there.
Looking the registry:
(Get-ItemProperty &...
0
votes
1
answer
79
views
Notepad with dark background and white font
I am using windows 10 with dark theme colors. My favorite applications, notepad, when high contrast setting is on becomes black with white font.
I would like my notepad to look like that, but without ...
0
votes
0
answers
63
views
Run PowerShell Script With Large Font Size
I want to run a powershell script with customized console properties without changing the default properties.
I know the default font size is too small for me (14).
I can change it permanently in ...
2
votes
0
answers
45
views
PowerShell script to determine whether "this" computer is activated through Active Directory
I run a set of tools on Windows machines, both domain-joined and stand-alone. One of the tools involves offline activation using a CAC. I would like to write into my script a switch that will bypass ...
0
votes
1
answer
161
views
How to Remove Preferred Languages from Microsoft Edge using PowerShell
I am trying to manage the preferred languages in my Microsoft Edge browser on Windows using PowerShell. Specifically, I want to remove certain languages that appear in the "edge://settings/...
1
vote
0
answers
61
views
How Can I Retrieve Information from Orphaned `.avhdx` Files When No Corresponding Hyper-V Checkpoints Exist?
I'm working with Hyper-V on a Windows system and have encountered an issue with some .avhdx files in my C:\Users\Public\Documents\Hyper-V\Virtual hard disks folder. These files appear to be different ...
1
vote
0
answers
44
views
Windows 10/11 NTFS permissions for Azure AD Group within Windows Folders
This post show how to handle permissions to users: Windows 10 NTFS permissions for Azure AD account
How can I use the same logic to add groups from Azure instead of users into Windows Explorer folders?...
1
vote
2
answers
127
views
Powershell in bat file closing console
I have a bat file that normalizes several audio files in one folder.
I create txt files with the same names as the audio files and I need to delete some lines from a txt file that will be used to ...
1
vote
3
answers
167
views
Powershell - keep only lines in txt files contain some selected words
I have a txt file and I would like to keep only a few lines in it
I want to a command that turns this
txt file:
;FFMETADATA1
title=TNT
disc=01
comment=
lyrics-eng=
\
\
\
album=Classic
genre=Older
...
1
vote
2
answers
263
views
How do we know if a ps1 file is executed from CLI or GUI?
When a ps1 file is executed, how do we know that the file is executed from CLI command line or from GUI Explorer (the file itself or another ps1 file)?
There are several reasons I ask this. One thing ...
0
votes
1
answer
53
views
How to delete directory called [ '.. ]
I am amazed by the things Windows lets you do, then doesn't let you undo.
Doing some programming, I ran a build script and specified the output folder as '../my/folder'
From this, it created a folder ...
1
vote
1
answer
146
views
Run Multiple Commands As Admin From PS1 File ( Windows Terminal)
This PS1 File (test.ps1), while executed, will run The Commands Pushd $Home; bcdedit /enum bootmgr; pause As Admin in PWSH.exe its self.
# test.ps1
$AL = "-NoProfile -WindowStyle Maximized -...
0
votes
1
answer
253
views
Turn off laptop display without putting it to sleep
I tried the suggestions on Turn off display in Windows on command and they aren't suitable.
The Screensaver method only blanks the display without turning it off. Maybe that would work for OLED users.
...
0
votes
2
answers
329
views
PowerShell equivalent to DISM's /Cleanup-Image in Windows 10
What is the PowerShell equivalent to DISM's /Cleanup-Image in this command:
DISM /Image:%mounted_image% /Cleanup-Image /StartComponentCleanup /Resetbase /ScratchDir:%scratch_dir%
Within Use DISM in ...
0
votes
0
answers
89
views
Why does the DISM command report the error 3 times if its run with all caps?
I'm trying to install a driver manually using its .cab file on windows. But I'm having an issue where dism is saying that it can't find the file even-though its clearly there.
DISM /Online /Add-...
6
votes
2
answers
742
views
Are there commands in PowerShell 7 to split the current window into four and request to run Python files in each of them?
Currently, I click + 3x while holding Alt to create four divided terminals within the same tab:
In each of these, I need to run a different Python commnd:
cd "C:\Users\Computador\Desktop\Test ...
1
vote
2
answers
106
views
Gaining administrator privileges from Function PowerShell
1. GetAdmin from function inside Script
function test {
GetAdmin
if ( $(fltmc).count -eq 3) { 'Not Admin' } else { 'Admin' }
write-host "`'$PSCommandPath`'"
pause; exit ...
3
votes
2
answers
406
views
What Equivalent %* of Batch in PowerShell
Batch Script:
@echo off
if not "!!"=="" setlocal enabledelayedexpansion
for /f "tokens=4*" %%a in (
'dir /AD "%USERPROFILE%\" ^| find "DIR" ^| Find /...
0
votes
1
answer
189
views
Why is start process minimized not working for some applications?
PowerShell code.
I tried these and they work properly:
Start-Process notepad -WindowStyle Minimized
Start-Process cmd -WindowStyle Minimized
But these do not work:
Start-Process control -WindowStyle ...
0
votes
1
answer
90
views
How to open the CMD or the PowerShell in the Windows terminal when you open them as Admin?
I noticed that when I open the CMD or the PowerShell in non-admin mode, it always opens in the terminal; however, when I open the CMD or the PowerShell as admin, it always opens the old window. Indeed,...
2
votes
3
answers
376
views
Start Powershell Maximized Thought Windows Terminal
Short Description: If pwsh/powershell is not running Maximized, re-open it Maximized
I have installed pwsh and wt, with pwsh as the default console in wt, and in some scripts, I want wt to run ...
0
votes
1
answer
119
views
CMD/Powershell looking for "curl" executable in the wrong location despite PATH
I have a strange issue with both CMD and Powershell on Windows 10 that has been giving me some trouble. An unrelated scriptwas failing when running curl, and after some investigation it looks like a ...
0
votes
1
answer
64
views
Can we get text scaling and monitor properties with WMI?
It is possible to use WMI to detect things like:
Text scaling
Screen resolutions
Multiple Monitor configuration/layout
?
I see Win32_DesktopMonitor but it doesn't seem to give me any of this info.
0
votes
1
answer
303
views
How do I make a command line always show in front of another app
let's say I only have one monitor and I open an IDE and a powershell window. I need to type words in the IDE's current tab while watching the conent of the command line.
The problem I have is, ...
0
votes
4
answers
156
views
How to auto power on windows laptop when lid is opened from shutdown state just like hibernation state?
It has been observed that most laptops power back on by themselves upon reopening the lid if they were in hibernation mode.
However, this behavior is not replicated when the laptop was in full shut ...
0
votes
3
answers
48
views
Powershell $idValue doesn't write the extracted ID, but writes "TRUE" instead -- why?
I am writing a Windows PowerShell script to split a text file based on a delimiter, and create output filenames with an incrementing number and a captured identifier string.
I've checked for syntax ...
0
votes
0
answers
196
views
Executing Powershell script automatically on domain join
I'm currently working on a customized Windows installation ISO, where local GPOs are predeployed (using LGPO.exe (Local Group Policy Object Utility) and SetupComplete.cmd). This image is targeted ...
0
votes
1
answer
240
views
Create a archive split into blocks of a maximum size using Windows shell
As example. I want to compress a directory of 100GB split into 10 archives of 10GB using cmd or powershell, non-interactive without installing additional tools. Using tar would be awesome but ...
0
votes
1
answer
265
views
What secure erase in the fastest way on Windows 10 with cmd? [duplicate]
I have a program in QT, C++ and I want to secure erase the computer after a trigger. After this process, I do not want the old data on the SSD to be accessed by data recovery programs. I want this ...
0
votes
0
answers
189
views
Need help creating local user accounts on 6 remote computers in a Windows workgroup
I am trying to create a simple script that prompts a local admin user to create a local user account on 6 remote computers in a Windows Workgroup. The script should prompt for the name of the user, ...
-1
votes
1
answer
134
views
Uninstall SourceTree using cmd or powershell
I would like to use cmd or powershell commands to uninstall SourceTree from windows 10 machines on my network. The reason I need a terminal way is that I have to do this remotely and simultaneously ...
0
votes
1
answer
63
views
Powershell, file.exe --help output not redirectable
I'm attempting to redirect the output of the help message from a binary to an output.txt file, but the help message isn't being redirected as expected. I've tried several different solutions, but none ...
1
vote
1
answer
578
views
How to run the powershell script simultaneously on multiple computers
I am trying to run the PowerShell script, which I have, on multiple computers simultaneously. Currently, I'm using PowerShell version 5.
I want to know is it possible to run it without background ...
0
votes
2
answers
1k
views
How to create and run the windows service using powershell script
I'm trying to create a new service (AppOneTest) on windows 2016, which should be available in services.msc and whenever the service starts (AppOneTest) it should start the process explorer
$...