Questions tagged [powershell]

Windows PowerShell is a command line shell and scripting language for Windows that supersedes the CMD.exe shell and batch language. PowerShell is also an automation engine for Windows that provides functionality similar to Windows Script Host and VBScript.

Filter by
Sorted by
Tagged with
2 votes
3 answers
1k views

How can I open a URL link from within an Excel cell (hyperlink) using a different browser than the default?

I have an Excel sheet with URLs that I want to open using a separate browser. I know how to set the default browser used by different apps using the windows built-ins: cmd /c assoc cmd /c ftype This ...
not2qubit's user avatar
  • 2,295
1 vote
2 answers
92 views

Is it possible to log events of every user in one Event Log?

Right now if AppLocker blocks a program it is only logged in the local EventLog of the user. Is it possible to set up one Event Log where the events of any user are logged that can be accessed by an ...
ylr's user avatar
  • 13
1 vote
1 answer
4k views

Parameter cannot be processed because the parameter name 'p' is ambigious

where am I going wrong please? In command prompt, you can see the following parameters can be used: This is the PSADT error: the following is my PSADT code: Execute-Process -Path '...
Jahed's user avatar
  • 13
-1 votes
1 answer
908 views

Installing SSMS in Windows Core

I'm trying to: start "" /w ".\smss-setup-enu19.exe" /passive ssmsinstallroot="c:\program files\ssms" but encountering this error:↓ (syntaxes using " around path and ...
mgae2m's user avatar
  • 35
2 votes
2 answers
6k views

PowerShell How to Get File Owner/Author?

Below script retrieve specific file types from the I: drive and outputting specific file properties to a delimited CSV file. How to return file owner and authors? Any help is very much appreciated. ...
panes-rubrics.0l_icloud.com's user avatar
0 votes
1 answer
429 views

Executing a certain command for files in multiple subfolders at once in windows powershell

I have a folder with multiple subfolders containing PDF files which I am renaming by executing this command in each of the subfolder; get-childitem *.pdf | foreach { rename-item $_ $_.Name.Replace(&...
Alan's user avatar
  • 101
1 vote
1 answer
2k views

Export all users for each Distribution Group I own into a csv

The below commands will extract all the Distribution groups I own. Get-DistributionGroup -ManagedBy [email protected] | Export-Csv -Path c:\temp\test.csv -NoTypeInformation Question: How can I ...
SSP's user avatar
  • 81
0 votes
0 answers
631 views

pass Keystroke to powershell in background, started with -w hidden

I am trying to learn powershell scripting and I have the following problem: A script needs to get a ENTER keystroke during its runtime so the first lines are executed before the 2nd part starts. The ...
p3ppi's user avatar
  • 1
0 votes
1 answer
343 views

Clear Powershell screen when typing prompt not available

I came from using Linux where you can clear the screen with Ctrl+L. After reading a bit on this form, I see people have been clearing powershell by typing in "CLS" or using binding "CLS&...
matohak's user avatar
  • 239
3 votes
1 answer
6k views

Is there a way to identify the PCIE Speed for a device using powershell (Win10)? [duplicate]

This way I can determine the transfer rate of the device and relate that to the generation of the PCIE device (PCIE 3.0, 4.0, etc)
Austen Huang's user avatar
1 vote
0 answers
436 views

Send keyboard input while session is disconnected

I have a task that I want to automate that basically requires running a GUI application, and sending it keypress input. I have a powershell that works for that purpose (though anything that uses out ...
soandos's user avatar
  • 24.4k
0 votes
1 answer
1k views

Create a New-PSDrive with username and a blank password

I have disabled the blank password restriction in the group policy. I'm unable to create a PS-Drive without the password with just code and no user inputs. $user = "Admin" $creds = New-...
Mohammad Yusuf's user avatar
3 votes
2 answers
16k views

Adding Header to CSV file using Powershell

I have a CSV file and data in CSV file looks like below its vertically formatted. that file is not having headers i want to add header to that file. when i tried to add using below powershell script ...
Ade's user avatar
  • 51
0 votes
0 answers
181 views

How to test CPU hot plug on Windows?

I tried CPU hot plug testing with Linux using the command lines : Set online/offline individual core or group cores: echo 0 > /sys/devices/system/cpu/cpu0/online echo 1 > /sys/devices/system/...
Thang Pham's user avatar
0 votes
1 answer
2k views

Output to 2 decimal places?

I am trying to change output of this to be 2 dec places: dir c:\ -Recurse -File | sort-object -property length | select name, @{Name=‘Length (GB)’;Expression={$_.Length / 1GB}} -last 10 I have tried ...
Matt's user avatar
  • 3
-2 votes
2 answers
279 views

Script to split a folder with thousands of (audio) files into subfolders of 74 minutes each

I have a folder with ~1600+ mp3 files, and i want to organize it in multiple "albums", i.e. subfolders where the total duration of the audio files inside doesn't exceed 74 minutes (the size ...
Vico's user avatar
  • 276
0 votes
1 answer
1k views

Powershell - How do I convert the length property to human readable? [duplicate]

Im sure there are other ways to do this, but im trying to learn and trying to see how I can convert this length output to GB format dir $env:USERPROFILE -Recurse -File | sort-object -property length | ...
Matt's user avatar
  • 3
1 vote
1 answer
129 views

How to batch select files that don't respect a pattern

I'm a new user of powershell and cmd and I need to select thousands of files that don't respect a certain pattern. The pattern is as follows : 7num_5num_2num And I was looking for a way to select ...
Amir Ghafouri's user avatar
0 votes
0 answers
42 views

Why this PowerShell replacement command encounters error?

I have a script that replaces the content of a given file: set IsSecure=false if "%Protocol%" == "https" ( set IsSecure=true ) powershell -Command "(gc %PublishRoot%\...
Ali EXE's user avatar
  • 175
0 votes
0 answers
1k views

The best approach to calculating SSD wear with crystaldisk command line

I installed crystaldiskinfo (Version 8.17.3) on a windows pc, and then ran the following command line function. cmd > "%ProgramFiles%\CrystaldiskInfo64.exe" /CopyExit This gives me a ...
Andy McRae's user avatar
0 votes
1 answer
729 views

Return employee time zone from AzureAD into Excel as non-admin user

How do I retrieve a user's home base time zone as a UTC offset through a query, accounting for current DST settings? I'm a regular non-admin user. I use Power Query* to retrieve our employee list from ...
Neman's user avatar
  • 330
0 votes
0 answers
814 views

Windows tar compress command doesnt appear to include subdirectories

I am trying to compress all files and folders in the current folder (on my Windows 10 environment) so I can extract them on my Raspbian environment. Im using a Powershell script with the tar command ...
Jimbo's user avatar
  • 161
19 votes
1 answer
27k views

how do I permanently set a system variable ([System.Environment]::SetEnvironmentVariable) in windows 11?

As above. I tried (inside powershell terminal with run as admin) [System.Environment]::SetEnvironmentVariable('ResourceGroup','AZ_Resource_Group') and the variable is only available for that window. ...
mrjayviper's user avatar
0 votes
0 answers
457 views

NVMe M.2 SSD keeps disappering every now and then whenever PC reboots

I have HP Z2 SFF G4 Workstation Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz 3.19 GHz with Windows 10 Pro 21H2. I have installed dropbox on NVME samsung SSd 970 SCSI 2GB and manually assigned it drive ...
Hemendr's user avatar
  • 149
1 vote
1 answer
37 views

Need assistance with strange progressive numbering on file extension

In this image: you can see that I was using Powershell to count the number of files by type, however, I noticed something unusual in the counts. That is, there are file extensions with progressive ...
Yndrel Bösch's user avatar
2 votes
2 answers
3k views

How to move a vhdx file?

On my host, I'm running Hyper-V (Windows Server 2022 Core in Hyper-V role). My host has a C: and a D: drive. I've got one VM, which is running Windows Server 2022. My VM has 2 vhdx files, one for ...
uncaged's user avatar
  • 173
0 votes
1 answer
246 views

How to dump stdin data in powershell to file?

I'm trying to dump stdin data (file/photos/videos etc) from local (linux/jailed iOS) to remote (Windows) via ssh. In normal situations where local and remote are linux, this works: #! /bin/bash dest=&...
papillon's user avatar
2 votes
1 answer
19k views

How to run a Powershell command in a batch script

How can I run the following command in a batch file? POWERSHELL -Command "& {Get-AppxPackage | %% { Add-AppxPackage -ForceApplicationShutdown -DisableDevelopmentMode -Register "$($_....
Austin Reed 's user avatar
1 vote
1 answer
12k views

How to invoke a command in PowerShell and get the output without having to wait for completion?

I use the following code to run a command and get the output : $result = Invoke-Command { .\SomeExecutable.exe } Write-Output $result It works but major issue is that I have to wait for completion (...
tigrou's user avatar
  • 921
1 vote
2 answers
876 views

How to suppress showing the whole current fold path in Windows terminal so that it will get as in Linux?

When you work in the Windows terminal, you see your full current fold path on the left. I would like to make it looking like in Linux where only the last directory name is shown, becasuse my current ...
Vovin's user avatar
  • 135
0 votes
1 answer
756 views

ssh-keygen -f option, with PowerShell, continues to say folder not exists despite it does

I'm using the PowerShell terminal in Windows 10. I created a folder "new_folder" in ~/.ssh mkdir ~/.ssh/new_folder Then I try to run ssh-keygen with the -f option. The documentation says &...
Alex 75's user avatar
  • 113
3 votes
1 answer
1k views

How to upgrade PowerShell?

I installed the PowerShell, and now I see a message when lauching it A new PowerShell stable release is available: v7.2.5 Upgrade now, or check out the release page at: https://aka.ms/PowerShell-...
serge's user avatar
  • 703
6 votes
0 answers
2k views

WSL command provides no output when run in Administrator console

I can run wsl commands 'wsl -l' etc from both command prompt, and powershell with no issue when the consoles are opened with user permissions. WSL command working in non-admin console: However, when ...
user1706036's user avatar
1 vote
2 answers
2k views

RunOnce key which starts elevated .ps1 file

so for few days I'm working on the automation script in powershell which starts elevated -> changes pc name -> creates the RunOnce reg file with this line as Value (program changes it ...
Marek's user avatar
  • 11
0 votes
3 answers
2k views

How can I remove or delete a specified part of a file name at a certain range of columns?

For instance say I have file1_6363, file1_6364 and file1_6365. I simply want to remove the first 63 as you can see there's another 63 in the first example and so far I've been using this PowerShell ...
AMIR's user avatar
  • 3
8 votes
1 answer
3k views

Manage Windows App Execution Aliases from PowerShell

Is it possible to turn off app execution aliases from Powershell? I am ideally looking for a command like: PS> Disable-AppExecutionAlias python Right now, the only way I can find to do this is by ...
iansedano's user avatar
  • 181
0 votes
1 answer
564 views

I need to restart my PC if theres no network connection after about 1 minute

I manage a number of Microsoft teams rooms. They do a nightly reboot and sometimes they come up without network. The environment they are in is very locked down so no ICPM traffic is allowed. What Im ...
Barrington's user avatar
2 votes
1 answer
2k views

Windows 11 pro - using task scheduler to send an email on shutdown?

How can I configure Windows 11 pro to send an email immediately prior to shutdown? I've written a simple powershell script to send an email (this works fine) but I'm having trouble persuading the task ...
ConanTheGerbil's user avatar
1 vote
0 answers
619 views

PowerShell script to copy files and iterate them depending on name and timestamp

Let me start by saying, I really don't know powershell. I am an pharma process automation engineer so my experience is programming PLCs and HMI design. I have written all sorts of languages but I am ...
sam's user avatar
  • 21
2 votes
1 answer
10k views

Access Denied installing updates remotely with Powershell

Im trying to install in a remote server, updates approved in our Wsus: $session=New-PSSession -ComputerName server1 Invoke-Command -Session $session -ScriptBlock { (Import-module -name "S:...
RAN55's user avatar
  • 53
2 votes
1 answer
2k views

In PowerShell, how to save a DateTime variable into a file to be retrieved later?

I want to log the timestamp when a certain line is executed so that the script can know how long it has passed since last execution of that line, even if the script is stopped in between and the ...
user167420's user avatar
0 votes
1 answer
1k views

Menu Bar not showing in Windows Powershell 5.1

I just installed the Windows Powershell in my windows 10 computer but the menu bar is not showing. I want to open new tabs and in the documentation it says one should click file, but my powershell has ...
eeqesri's user avatar
  • 103
1 vote
2 answers
131 views

Moving files into separate folders

I have a folder in which I create multiple screenshots per day '[projectname].[date].[time].png' So it looks like this: ProjectAlpha.2020-11-10.09-53-21.png ProjectAlpha.2021-05-20.15-10-43.png ...
Karel's user avatar
  • 13
1 vote
0 answers
228 views

PowerShell script to copy files, iterate duplicates with different time stamp, and ignore duplicates with same time me stamp

Let me start by saying, I really don't know powershell. I am an pharma process automation engineer so my experience is programming PLCs and HMI design. I have written all sorts of languages but I am ...
sam's user avatar
  • 21
2 votes
1 answer
406 views

Custom Scheduled Tasks in Win11 causing PowerShell & CMD.exe pop-ups - how to make them silent / background tasks?

How can I make these run silently in the background? Here is my PowerShell script: rm C:\*.jpg rm C:\*.doc rm C:\*.pptx rm C:\*.xls rm C:\Users\*.jpg rm C:\Users\*.doc rm C:\Users\*.pptx rm C:\Users\*...
SamAndrew81's user avatar
0 votes
1 answer
11k views

Powershell script completely removing user profile, user's folder, and user's registry key for dormant accounts

I'm trying to create a Powershell script that removes from a Windows computer a user's profile, a user's folder in "C:\Users", and a user's registry key in "HKLM:\Software\Microsoft\...
Korey Mendes's user avatar
2 votes
1 answer
1k views

How do i return true/false on get-content command for each username inside C:/Users?

We want to eliminate the existence of a bad config file we've identified (and also have the manual fix for) from within every users appdata folder. The config file only exists here and there and not ...
Mastaxx's user avatar
  • 1,218
1 vote
3 answers
8k views

Removing a staged AppxPackage

On Windows Enterprise 10.19044.1708 21H2, I'm trying to use Remove-AppxPackage PowerShell cmdlet to uninstall the Microsoft 3D Viewer app. I have it down to the point where it's no longer showing as &...
JamesTheAwesomeDude's user avatar
0 votes
0 answers
776 views

Why does the Execution Policy Change prompt pop up 50% of the time?

Execution Policy Change The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the ...
gargoylebident's user avatar
3 votes
1 answer
4k views

Forcing lock screen image not working

I want to force the same lock screen image on every user. I selected the image I want with group policy Local Computer Policy > Computer Configuration > Administrative Templates > Control ...
VidathD's user avatar
  • 139

1
16 17
18
19 20
117