New answers tagged

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....
user avatar
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 ...
user avatar
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 ...
user avatar
  • 3,927
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 ...
user avatar
0 votes

How to resolve: "Unregister-ScheduledTask : The system cannot find the file specified." error in powershell?

You missed -TaskPath argument.
user avatar
  • 1,734
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 ...
user avatar
  • 140
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 ...
user avatar
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 ...
user avatar
  • 266
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 &...
user avatar
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 | ?...
user avatar
  • 6,929
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&...
user avatar
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-...
user avatar
  • 6,929
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:\", &...
user avatar
  • 56k
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: ...
user avatar
  • 6,929
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(&...
user avatar
  • 3,927
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 &...
user avatar
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.
user avatar
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 (...
user avatar
  • 6,929
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-...
user avatar
  • 3,927
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 "&...
user avatar
  • 457
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\...
user avatar
  • 457
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 ...
user avatar
  • 1,977
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 ...
user avatar
  • 457
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 ...
user avatar
  • 69
-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 ...
user avatar
  • 457
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 &...
user avatar
  • 457
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 ...
user avatar
  • 457
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).
user avatar
  • 411k
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-...
user avatar
  • 521
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 ...
user avatar
  • 3,927
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))...
user avatar
  • 6,929
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 ...
user avatar
  • 74
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 ...
user avatar
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 ...
user avatar
  • 68.1k
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 ...
user avatar
  • 3,927
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 ...
user avatar
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('...
user avatar
  • 1,977
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, ...
user avatar
  • 1,977
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 = "...
user avatar
  • 1,385
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 850
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 ...
user avatar
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'...
user avatar
  • 6,929
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 (...
user avatar
  • 3
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 ...
user avatar
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 ...
user avatar
  • 8,060

Top 50 recent answers are included