New answers tagged powershell
0
votes
Cannot reinstall Calculator: Microsoft.UI.Xaml.2.0 missing
For anyone looking for the command in 2022 to install to all users. Follow KreonZZ's steps then install in PowerShell with this:
DISM.EXE /Online /add-ProvisionedAppxPackage /PackagePath:.\Microsoft....
1
vote
Accepted
Windows Connection to Local Computers is Slow by Name but Fast by IP Address
Have you tried the host file?
Add the following lines to C:\Windows\System32\drivers\etc\hosts:
192.168.0.201 BOB-COMPUTER
192.168.0.202 JOE-COMPUTER
192.168.0.209 JOHN-COMPUTER
Maybe this won't ...
1
vote
Accepted
how to escape the line to run powershell
As per my comment, from your other post, where I provide feedback. This is what I mean.
The below will work as shown...
@echo off
cls
::
title cpm
color e
::
::
cls
PowerShell -Command 'Hello from ...
0
votes
Is it possible to have scripts run in Windows Terminal by default?
Yes you can. I tried to customise my PowerShell terminal, Developer PowerShell terminal and CMD terminal with ASCII art. The way you can do this is to hack the terminal a little bit. I will give the ...
0
votes
How to resolve: "Unregister-ScheduledTask : The system cannot find the file specified." error in powershell?
You missed -TaskPath argument.
0
votes
Get service name from it's PID (powershell)
Here's another way - those above might be more reliable?
$id = 5556
# (debugging) Nice little table to make sure you've got the right thing...
Get-Process | Where-Object Id -EQ $id | Select ...
0
votes
How to update PSReadline properly in PowerShell 7.2.5?
All instances of Powershell need to be closed. (Don't forget vscode, windows terminal, etc. which might run one.)
You may then remove the folder PSReadline from Program Files using Windows Explorer ...
0
votes
how to fill fields of a dialog in ie with powershell?
Typically when accessing a website through basic authentication you can include the username and password inline with the URL like this:
http://<username>:<password>@192.168.1.1
Or with ...
0
votes
how to escape the line to run powershell
As you are writing a batch script, you can use the ^ (as you did before editing the question) for line continuation. Remove the " you added at the beginning of the Powershell command. Add the &...
0
votes
Accepted
How can I set the value for each default key in different subdirectories of regedit?
PowerShell:
Get-ChildItem Registry::HKCR\mplayerc64.* -Recurse |
Where PSChildName -eq 'Shell' |
Set-ItemProperty -Name '(Default)' -Value 'enqueue'
Aliased:
gci Registry::HKCR\mplayerc64.* -s | ?...
0
votes
How can I set the value for each default key in different subdirectories of regedit?
Export the Registry key and subkeys as one .reg file, e.g., no_def.reg.
Open in the.reg file in a text editor, such as Notepad or Notepad++.
Manually, or by search-and-replace, insert `@="enqueue&...
0
votes
Powershell - Find and move files with specific extension while retaining folder structure
This should create the necessary folders if they don't exist:
get-childitem "D:\*" -Filter *.mp4 -recurse | ForEach{
$TargetPath = $_.DirectoryName -replace ('^C','A')
If (!(Test-...
0
votes
Powershell - Find and move files with specific extension while retaining folder structure
You could accomplish this using something like this:
get-childitem "D:\*" -Filter *.mp4 -recurse | foreach-object {
$source = $_.FullName
$target = $Source.Replace("D:\", &...
1
vote
Accepted
PowerShell/CMD command to map metadata from one set of files to another, in different drives
Untested, but I think this would do the trick:
$new = 'C:\Users\xxxxx\Desktop\new'
$new2 = 'S:\new2'
$temp = ( mkdir "$env:tmp\$((Get-Date).Ticks)").FullName
$TroubleShoot = @'
MetaSource: ...
1
vote
What is the Windows equivalent of xset command
If you run this in the console:
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
... and then press any key, you get a return value that you can extrapolate from.
$Host.UI.RawUI.ReadKey(&...
0
votes
retrieve only numbers from a file with powershell
Try the following:
(Get-Content -Path 'C:\Path\to your\file.txt') -replace "\D","" -replace "^\d{1,3}$","" -replace "^\d{8,}","" -match &...
0
votes
Accepted
Can't Access new AWS EC2 instance but can access existing instances
Updating Putty from 0.74 to 0.77 resolved the issue for me. Frustrating.
0
votes
Powershell script several issues
For #2:
Most likely you didn't create the directory SysNetInfo under c:\tmp. PowerShell file writing commaands will create the file but not the directory/directories.
Use something like:
If ( -not (...
1
vote
Accepted
retrieve only numbers from a file with powershell
Just read the file and get only digit match, using the Get-Content using the -replace switch using regex to get your data. What you are after is common string replacement.
# https://wisetut.com/only-...
0
votes
how to escape the line to run powershell
I am not sure of your intent but the command line Powershell commands are a little off. I believe you want something similar to what I have below, but you may want to move the clear screen call "&...
0
votes
Script to split a folder with thousands of (audio) files into subfolders of 74 minutes each
-- This will be a mix of actual and pseudo code --
In Powershell, to get the Length of an MP3 file we can use this excellent Display Extended File Attributes function:
$dir_nam = "C:\Users\...
0
votes
Installing SSMS in Windows Core
I happened to have a windows server core (2012 R2) VM to test this on. Running this cmd command worked fine. I got a pop-up window with an installation progress bar for each component until it was ...
0
votes
Accepted
Parameter cannot be processed because the parameter name 'p' is ambigious
To start, I believe your password is incorrectly formatted and its location should also be changed.
The way you have it with the -p kjlz6wm, you are setting the password in Powershell itself. But you ...
1
vote
How to determine if a file with a trailing space exists?
I found out the problem isn't Powershell - it's Windows. However, Windows does have a way to force a literal string: prepend \\?\ to a path:
For file I/O, the "\\?\" prefix to a path ...
-1
votes
How can I open a URL link from within an Excel cell (hyperlink) using a different browser than the default?
This is fairly simple using Powershell and the ImportExcel module: In my example my spreadsheet has three columns, DATE, URL, OTHER_INFO and the URL column has the links.
Install the ImportExcel ...
0
votes
Export Excel sheet as CSV, with regional settings
If the $ws variable is already well formed, I suspect you can simplify it by simply exporting it as a CSV and setting the delimiter:
$ws | Export-Csv -NoTypeInformation -Delimiter ";" -Path &...
0
votes
How to bold some lines in a Microsoft Word table cell using PowerShell
I think you are really close, on the two lines
$Table.cell(1,1).range.Bold=1
$Table.cell(1,2).range.Bold=1
Change the =1 to =$True.
$Table.cell(1,1).range.Bold=$True
$Table.cell(1,2).range.Bold=$True
...
2
votes
-P option on wget does not work on windows 11
The wget command in PowerShell is an alias for a PowerShell-native
command named
Invoke-WebRequest
that doesn't have these parameters.
Use instead the wget product from the Command Prompt (CMD).
0
votes
Export Excel sheet as CSV, with regional settings
Working with Excel COM objects in PowerShell takes some doing sometimes..
When using a method that takes multiple parameters of which you want to set just some, you need to also set the parameters in-...
1
vote
Windows: How to get list of running apps sorted by time they were lastly used?
As per @ReddyLutonadio', you'll get:
Get-Process |
Where {$_.MainWindowTitle } |
ForEach { Get-ChildItem $_.Path} |
Select Name, LastAccessTime |
Sort LastAccessTime
# Results
<#
Name ...
1
vote
PowerShell How to Get File Owner/Author?
Owner and Author can be retrieved using the Shell com object:
$shell = New-Object -com shell.application
gci | select name,
@{N='Author';E={$shell.NameSpace(($_.DirectoryName)).ParseName(($_.Name))...
0
votes
Check whether Windows Updates are being installed
For Windows Update service IsBusy status you can use:
$objInstaller=New-Object -ComObject "Microsoft.Update.Installer"
$objInstaller.IsBusy
If you want to wait around until the service is ...
0
votes
Accepted
Is it possible to log events of every user in one Event Log?
You might look at Nirsoft's free FullEventLogView, which combines views of all Windows Even Logs, from all users. into one view, and which allows viewing logs on other machines, or one of the many ...
0
votes
Is it possible to log events of every user in one Event Log?
Windows administrators can remotely connect to the logs of of the Windows PCs in their domain.
If you are just looking for a single event, you could write a script to scan the log for an event and ...
1
vote
PowerShell How to Get File Owner/Author?
Owner and author are different things.
Yet, why overcomplicate the first part, meaning base file properties and ACL stuff? Why not just this for file properties and access control details. No Get-Acl ...
1
vote
Accepted
Export all users for each Distribution Group I own into a csv
The PowerShell #1 solution will dump the name of the member and name of the group into one csv file and more accurately matches the example logic you provided.
This solution uses select-object to add ...
2
votes
Accepted
Is there a way to identify the PCIE Speed for a device using powershell (Win10)?
This method uses the WMI Bus PnP device driver properties
# Get all devices related to PCI BUS
$pciStats = (Get-WMIObject Win32_Bus -Filter 'DeviceID like "PCI%"').GetRelated('...
1
vote
Accepted
Clear Powershell screen when typing prompt not available
This is not specific to powershell, as it affects anything running in the built-in terminal.
Unfortunately, there is no way to do this from that built-in terminal that the .EXE for powershell, cmd, ...
0
votes
Adding Header to CSV file using Powershell
You ask for "output i am expecting(only want headers added)"
using your example the following does what you ask.
$File = 'O:\Temp\Import.csv'
$Data = Get-Content -Path $File
$Header = "...
0
votes
All of the about_* topics are missing from my PowerShell help. What gives?
It was stupid locale for me. Get-UICulture returns en-GB, but apparently help is only available in en-US, because of course it is.
Update-Help -Force -UICulture en-US -Verbose
Works fine on 7.2.4 on ...
0
votes
How to set default app per filetype programmatically?
Although this post is over 3 years old, the SetUserFTA might help you.
See references here and here.
It worked for me to programmatically set the default browser in Windows 10 and it should work for ...
0
votes
Adding Header to CSV file using Powershell
Import-CSV only treats literals between double quotes. You need to define them as " " or "John ". So your original CSV file is poorly formatted for your needs. You'll ...
0
votes
Difference between ScriptProperty and Method
ScriptMethod: A method that is implemented from a PowerShell Scripts.
Example:
$A = Get-ChildItem C:\Temp\test.txt
$S = {[math]::Round(($this.Length / 1MB), 2)}
$A | Add-Member -MemberType ...
1
vote
Accepted
How to batch select files that don't respect a pattern
PowerShell:
Assumptions:
Single top-level folder (can be modified to search multiple paths)
Top-level folder has sub-folders (hence the -Recurse parameter)
Get-ChildItem -Path $Source -Filter '*.jpg'...
0
votes
Output to 2 decimal places?
I got an answer on this, it works both ways!
Get-ChildItem -Path c:\ -Recurse -File |
Sort-Object -Property length |
Select-Object -Last 10 -Property name,
@{Name = 'Length (...
0
votes
Script to split a folder with thousands of (audio) files into subfolders of 74 minutes each
A CD of ~650 MB holding MP3 files can hold about ten hours in terms of playing time.
You state you have MP3 files, and that format significantly compresses audio, with some loss of fidelity. If you ...
0
votes
Accepted
Powershell - How do I convert the length property to human readable?
Unfortunately there is no easy -h like in Linux. You could do it like this:
select *,@{n='Length (GB)';e={$_.Length / 1GB}} -exclude length -last 10
Basically you select every property (*) add a ...
Top 50 recent answers are included
Related Tags
powershell × 5046windows × 1338
windows-10 × 790
command-line × 745
windows-7 × 292
script × 272
cmd.exe × 262
batch × 207
batch-file × 128
networking × 110
windows-registry × 92
active-directory × 92
ssh × 91
linux × 84
scheduled-tasks × 82
windows-8 × 78
bash × 77
csv × 60
python × 59
shell-script × 59
powershell-ise × 58
automation × 57
group-policy × 50
regex × 48
microsoft-excel × 47