New answers tagged

0 votes

Handling of forward/back slashes by Windows Powershell

PowerShell does not "know" that there is a Linux computer on the other side. The fact that the copy works means that PowerShell uses a copy method that avoids the need for knowing that. It's ...
harrymc's user avatar
  • 465k
0 votes

Update-help fails to update two modules

The main issue (among others) is that MS refuses to fix the case dependence of the module directories. They are basically shipped with the wrong case of the directory names and you need to rename them ...
not2qubit's user avatar
  • 2,117
0 votes

How to manage powershell script in task sequence (MDT)?

instead of using run powershell script goto ADD>Run Command Line and use above command. please check and confirm. check below link https://247-it.io/en/mdt-running-powershell-script-during-...
TaPP's user avatar
  • 1
2 votes
Accepted

What's the difference between takeown and Set-Acl for changing ownership?

They do effectively the same thing, but here's one difference you might be remembering. takeown /F file.txt technically only requires the "Take Ownership" NTFS file permission, and does not ...
Cpt.Whale's user avatar
  • 6,230
1 vote
Accepted

How to convert multiple embedded PNGs to JPEGs in Powerpoint file? - Filter PNGs by size

Without testing it myself, I think that changing in the PowerShell script the following line : $zip.Entries | ? {$_.FullName -like 'ppt/media/*.png'} | % { to this : $zip.Entries | ? {$_.FullName -...
harrymc's user avatar
  • 465k
1 vote

What's the difference between takeown and Set-Acl for changing ownership?

Set-Acl is a powershell command, and takeown is a Command Prompt command. Command prompt commands also works in powershell, but their output is not structured to easily work with powershell. Given you ...
LPChip's user avatar
  • 60k
1 vote
Accepted

How to apply `Convert-SidToName` to list of entries?

Replace select SecurityIdentifier with select -ExpandProperty SecurityIdentifier to pipe the SID values as a list of strings instead of objects. Depending on whether ConvertFrom-SID is written to ...
Cpt.Whale's user avatar
  • 6,230
-1 votes

PowerShell 7 "Where-Object" and its aliases return nothing

You can use the where utility CMD uses (for example, where.exe python).
LyndonGingerich's user avatar
1 vote
Accepted

"dir like" sorted by time in a batch file (.bat) using a piped string command: Get-ChildItem | Sort-Object -Property LastWriteTime, not working

First, the command is : Get-ChildItem | Sort-Object -Property LastWriteTime Second, PowerShell scripts are run from .ps1 files. If you wish to run them from CMD/batch, use the powershell command: ...
harrymc's user avatar
  • 465k
-1 votes

Sysinternals Handles Close Command?

Using the csv output and powershell, it's pretty straightforward. These days you need the numeric PID to close a handle, otherwise you'll just get the usage help message. Handle64.exe may crash ...
js2010's user avatar
  • 593
1 vote

Fast kernel reboot with Windows 10 : how to execute a quick partial reboot with a powershell script?

My understanding is that you wish to automatically logoff and then login back as the same user. This is impossible in one PowerShell script, as it would be terminated by the logoff, but there is a ...
harrymc's user avatar
  • 465k
1 vote

Powershell script with infinite loop and sleep - good or bad?

A script running 24/7 in an infinite loop is not a good idea. Although it will probably work, once your script hangs for an unknown reason, it terminates and it stops working. You won't know that it ...
LPChip's user avatar
  • 60k
1 vote

Export users without a manager or title, excluding disabled accounts

Use the -Filter parameter with the Get-ADUser command to retrieve enabled accounts, and pipe that through Where-Object to filter and obtain objects with null values for either 'manager' or 'title' ...
Vomit IT - Chunky Mess Style's user avatar
1 vote
Accepted

WingetUI: 'the server certificate did not match the expected values' - Kaspersky Protection changes the certificate that wingetUI expects

I found winget recently introduced certificate pinning for the windows Store source, so it won't allow SSL inspection even if your computer trusts Kaspersky. You can disable this for winget with ...
Cpt.Whale's user avatar
  • 6,230
2 votes
Accepted

Powershell and Get-ChildItem - why does adding a parameter change the output format?

What you're seeing is the - unfortunate - situationally varying stringification of System.IO.FileInfo and System.IO.DirectoryInfo instances output by Get-ChildItem in Windows PowerShell. This problem ...
mklement0's user avatar
  • 1,991
1 vote
Accepted

Powershell randomly flashes open on Windows 11?

The problem PowerShell job turned out to be a scheduled task for certbot that needed to be disabled. To track the task, you need to in the Task Scheduler to click "Enable All Tasks History", ...
harrymc's user avatar
  • 465k
0 votes

LDAP manipulation - Powershell or any other langage?

Powershell probably still works best, but you would use the .net [System.DirectoryServices] class methods. If the LDAP server is similar enough to active directory, you can do a simple LDAP bind+query ...
Cpt.Whale's user avatar
  • 6,230
2 votes
Accepted

Switching 'net' Command Output Language in Windows 11

How can I convert the output or account/group names to English? You'll have to do it yourself, unfortunately, as it seems that the names as well as the descriptions of built-in user and group ...
mklement0's user avatar
  • 1,991
0 votes

Change Windows Display Language (Windows 10) - Local Experience Packs (LXPs) - via CMD/Powershell

In the meantime it is also possible as an alternative to install the language pack via powershell: Install-Language de-DE Set-SystemPreferredUILanguage de-DE Requirement for this is Windows 10 20H2 ...
MarkusE's user avatar
  • 73
1 vote

Running GitHub Actions unders specific, existing Windows user

under a specific, already existing Windows user It is not an "already existing user", because the VM is not part of the Active Directory domain in which the user exists. There is no ...
u1686_grawity's user avatar
0 votes

Export/import compressed WSL2 distros

This is a an example of exporting a WSL distro with an on-the-fly compression. It is slower (10G/12min w compression vs 10G/8min w/o compression), but the compressed size is about the 1/10 of the ...
Arz's user avatar
  • 1
1 vote

How do you run an application as TrustedInstaller or SYSTEM without using external programs?

BTW, here's a .ps1 script made out of @hasto's commands: $ConfirmPreference = "None" $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent())....
mirage0x0000's user avatar
2 votes
Accepted

Update contact folder with Microsoft Graph API

You can use HTTP request, which is a direct way to call Microsoft Graph API and gives you more flexibility to control the request and response. You can use the GET method to get the incremental ...
Faery's user avatar
  • 619
0 votes

Powershell and Get-ChildItem - why does adding a parameter change the output format?

Try the following two experiments: Get-ChildItem c:\my_files | sort LastAccessTime | gm and Get-ChildItem c:\my_files -Exclude *[0-9].log | sort LastAccessTime | gm Take a close look at the output. ...
Walter Mitty's user avatar
0 votes

Move files from local to network drive without stealing away focus on production computer

Use a windows service manager. A windows service can't popup stuff even if it wanted to. A windows service manager is an application that will run any exe or script as a windows service. This will ...
Señor CMasMas's user avatar
0 votes

I can run Get-ADuser on a machine that does NOT have RSAT installed. How is this possible?

Get-AdUser is a cmdlet offered in the ActiveDirectory PowerShell module, and possibly others. As mklement0 notes you can see which module it is available from by running the command (Get-Command Get-...
music2myear's user avatar
0 votes

WindowsPowerShell/v1.0/powershell.exe

I think i might have a found the program causing this issue it Get-Process -Id 4056 | Select-Object Id, ProcessName, HandleCount, StartTime seems to be saying that a process id 4056 is the issue. So ...
Anthony rono's user avatar
0 votes

Enable Encryption for DoH on Win11 22H2

Solution for both IPv4 and IPv6 of Cloudflare DNS: $i = Get-NetAdapter -Physical $i | ForEach-Object { Set-DnsClientServerAddress -InterfaceAlias "$($_.InterfaceAlias)" -ServerAddresses &...
Võ Nguyễn Minh Tú's user avatar
0 votes
Accepted

Run Microsoft Office apps in guest VM from host with VirtualBox

Solution The issue comes from VirtualBox Guest Additions v7. Downgraded to a v6 version solve the problem. Details Host OS: Ubuntu 23.10 Guest OS: Windows 10 VirtualBox: v7.0.10 In the Windows 10 VM,...
TVG's user avatar
  • 121
0 votes

How to find out PCI device by Location Path

I know this is older, but I stumbled upon this thread while I was researching my own get-pnpdevice Powershell issues. I needed the name of the location path property and found it here, thanks! And ...
clong's user avatar
  • 1
0 votes

Update contact folder with Microsoft Graph API

Remove the New-MgUserContactFolder commands from your script. Otherwise it should run fine as-is to import your CSV to everyone's personal contacts. It will not overwrite the whole folder or delete ...
Cpt.Whale's user avatar
  • 6,230
0 votes
Accepted

Connect-ExchangeOnline with credentials - no browser

If -InlineCredential works at all, then -Credential will work too. If the account uses 2FA, you will get an error for either method: AADSTS50158: External security challenge not satisfied. User will ...
Cpt.Whale's user avatar
  • 6,230
0 votes

How to uninstall a Windows Update (patch) in silent mode using terminal or PowerShell?

powershell script: (dism /online /get-packages /format:table) | ForEach-Object { $tmp=$_ ; $tmpArr=$tmp.Split("|") ; if ( $tmpArr.Length -eq 4 ) { $tmpName=$tmpArr[0].Trim(" ") ; $...
ivan ivanov's user avatar
1 vote

Update Powershell through command line

This worked for me: dotnet tool update --global PowerShell Tool 'powershell' was successfully updated from version '7.3.3' to version '7.3.9'. Thanks to @LosManos for this comment
FMFF's user avatar
  • 143
1 vote

WinSCPSession error in parameter name 'HostName'. How it fix?

The parameters you are using should go to New-WinSCPSessionOption, not New-WinSCPSession. Like this: $sessionOption = New-WinSCPSessionOption -HostName $ftpServer -PortNumber $ftpPort -Credential (New-...
Martin Prikryl's user avatar
2 votes
Accepted

Powershell (windows 11) move files and rename

Here is how I ended up changing the command to make it work: foreach ($file in Get-ChildItem BM_Math_Test_Record_QA_* ) {Move-Item -Path $file -Destination ($file.Directory.ToString()+"\...
psycoperl's user avatar
3 votes

Powershell (windows 11) move files and rename

$_ doesn't work in bare commands – it is only defined inside loops such as ForEach-Object. Some cmdlets directly take a list of objects as input without doing anything special, but once you want to do ...
u1686_grawity's user avatar
0 votes

How to get OS Version through Powershell with WMI?

For output similar to what you would see in System Information here's an expansion of the comment from LotPings and called out in answer from marijnr Example Output: Windows 10 Enterprise 22H2 - 19045....
Starfield Screensaver's user avatar
0 votes

Missing Parameters in PowerShell Firewall Outbound Rule Command

One or more essential parameters were not entered You've missed two vital parameters: dir and action. These parameters define the rule's direction, which can be either inbound or outbound, and the ...
Vomit IT - Chunky Mess Style's user avatar
0 votes

Reset Bluetooth Components Without Having to Reboot

I've frequently had this problem when connecting my Logitech K480 keyboard to my ThinkPad X1. Often when the laptop wakes from a low-power state, either hibernation or sleep, the keyboard won't ...
Billious's user avatar
  • 113

Top 50 recent answers are included