86
votes
How to search Powershell command history from previous sessions
Press Ctrl+R and then start typing, to search backward in history interactively. This matches the text from anywhere in the command line. Press Ctrl+R again to find next match.
Ctrl+S works like above,...
76
votes
Accepted
How to search Powershell command history from previous sessions
The persistent history you mention is provided by PSReadLine. It is separate from the session-bound Get-History.
The history is stored in a file defined by the property (Get-PSReadlineOption)....
63
votes
ssh on windows - Corrupted MAC on input
Raoul's answer to his own question is correct. I ran into the same issue and adding the correct algorithm name after the -m option works (in my case the option was -m hmac-sha2-512 to connect from ...
55
votes
Accepted
How do I add the Windows GUI to Windows 2016 Server Core?
It's no longer possible to switch from Server Core to the full GUI or vice versa in Server 2016 - either through Server Manager, PowerShell, or DISM. You must make the choice initially at install ...
31
votes
Adding a user to the local Administrator group using powershell
On Server 2016 and Windows 10 Version 1607 and later you can use the new PowerShell local user cmdlets:
Add-LocalGroupMember -Group Administrators -Member username
This was added in Windows ...
30
votes
Accepted
How can I programmatically cause a new Windows user's profile to be created?
Windows can create a user-profile on-demand, using the CreateProfile API
However, if don't want to create an executable to perform this operation, you can call the API in PowerShell. Others have ...
30
votes
Accepted
Cause of Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes
Set the following registry key:
Windows Registry
Computer\HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access\On
to value 0 and reboot.
I discovered this alternative solution via the issue ...
27
votes
Public Key Authentication Windows Port of OpenSSH
Wow. Just spent a couple of hours debugging this.
So, turn logging for the ssh server:
Edit /ProgramData/ssh/sshd_config
Ensure you have SyslogFacility LOCAL0
Ensure you have LogLevel DEBUG3
...
27
votes
Set service StartType to Automatic - Delayed
No direct way in PowerShell, just use sc
sc.exe config NameOfTheService start= delayed-auto
in older versions of Windows you needed a space after the equal sign, this doesn't seem to be required ...
26
votes
How to ignore an error in Powershell and let it continue?
Short answer:
Add $ErrorActionPreference = 'SilentlyContinue' at the start of your code so you don't need to add -ErrorAction SilentlyContinue to every command
Long answer:
Controlling Error Reporting ...
22
votes
Accepted
PowerShell pipe into find.exe command
PowerShell evaluates the content within double quotes to perform any variable expansion, sub-expressions, etc, then it discards those double quotes. What PowerShell returns from "443" is literally 443 ...
21
votes
Accepted
Powershell module 'servermanager' not found on Windows 10
You need to download and install 'Remote Server Administration Tools for Windows 10'. The download link is https://www.microsoft.com/en-au/download/details.aspx?id=45520
RSAT tools on Windows 10 ...
20
votes
Windows Powershell Vim Keybindings
PSReadline module provides this.
To install is simple not sure what the requirements are but I think at least windows 10 for this method provided. If you dont have OneGet or not sure you can follow ...
19
votes
How can I programmatically cause a new Windows user's profile to be created?
All you need to do is run a command as that user, Windows will create the profile:
psexec.exe -u foobar -p Abcd123! cmd.exe /c exit
https://docs.microsoft.com/en-us/sysinternals/downloads/psexec
18
votes
Accepted
Why isn't MacTripleDes algorithm output in PowerShell stable?
MACTripleDES is different than the other algorithms that are offered by the Get-FileHash cmdlet. I'm not sure why it was included in the cmdlet, to be honest. It doesn't fit with the others, IMO.
...
17
votes
PowerShell prompt to continue execution of code
You Can use write-warning option. quite sleek:
Write-Warning "This is only a test warning." -WarningAction Inquire
WARNING: This is only a test warning.
Confirm
Continue with this operation?
[Y] Yes ...
16
votes
Accepted
PowerShell prompt to continue execution of code
Another simple solution would be to use:
Read-Host -Prompt "Press any key to continue or CTRL+C to quit" | Out-Null
I believe this is a better solution to the currently accepted answer ...
16
votes
Accepted
Create Code Signing Certificate on Windows for signing PowerShell scripts
There is no need in OpenSSL on Windows. On Windows 7, you can use my own PowerShell script I published on TechNet Script Gallery: Self-signed certificate generator (PowerShell). The usage can be ...
15
votes
Change the Powershell $profile directory
As @FrankMerrow posted, on this Stack Overflow question you will find the answer, but the correct is the one from Neck Beard, I'll copy it here.
As @woter324 points out issuing $profile | select * ...
15
votes
How do I completely turn off Windows Defender from PowerShell?
After going for hours through the docs: https://docs.microsoft.com/en-us/powershell/module/defender/index?view=win10-ps
Just decided to uninstall it. This works on WS 2016 with PS 5.1.
Remove-...
15
votes
Search Active Directory for computers logged in, in the last 30 days
Get-ADComputer -Filter * -Properties *
Only get the properties that you intend to use... it's more efficient. Retrieving all the properties of all computers in the domain when you don't really need ...
15
votes
Used PowerShell to change my RHEL root passwords via PuTTY, but I don't know what I changed my password to
The problem is you are trying to pass SecureString into something that expects a standard string. The Password property is in SecureString format, you won't be able to pass this to plink, it will just ...
15
votes
Cause of Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes
There is a fix for this error.
Powershell issue #11751
Create a .ps1 file, paste the following code and run it with powershell.
Add-Type -TypeDefinition '
using System;
using System.ComponentModel;
...
14
votes
Gaining administrator privileges in PowerShell
You can use this to self-elevate a script when ran:
#at top of script
if (!
#current role
(New-Object Security.Principal.WindowsPrincipal(
[Security.Principal.WindowsIdentity]::...
14
votes
Accepted
Azure Powershell - Change Directory
You need to specify the TenantID parameter when using Select-AzureRMSubscription:
Select-AzureRmSubscription -SubscripitionID <ID of sub> -TenantId <ID of Azure Tenant>
You can actually ...
14
votes
Accepted
How do I install an app from Windows Store using Powershell
You can now use winget to install msstore apps on windows 10 and 11.
Use winget search <app_name> --source=msstore to make a search, and use the id of the app to install and upgrade the app.
For ...
13
votes
Force-remove files and directories in PowerShell fails sometimes, but not always
Update: Starting with (at least) Windows 10 version 20H2 (I don't know that Windows Server version and build that corresponds to; run winver.exe to check your version and build), the DeleteFile ...
13
votes
Add a binding to an IIS site using powershell
I went through the process of trying to add an https binding to a site and it can be pretty painful. There are a lot of ways to accomplish each step and each one has pitfalls. I am leaving behind ...
13
votes
Accepted
What version of Windows Management Framework is installed?
See this documentation from Microsoft:
https://web.archive.org/web/20170826230335/https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell?view=powershell-5.1
In the &...
13
votes
Accepted
Powershell equivalent of Ctrl+R?
You can fix this by adopting the PSReadLine module.
See an article on the Hey, Scripting Guy! blog regarding this bash inspired readline implementation for PowerShell.
In particular, the usage of ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
powershell × 4126windows × 753
active-directory × 548
scripting × 278
exchange × 212
windows-server-2012-r2 × 207
windows-server-2008 × 177
azure × 166
windows-server-2008-r2 × 164
exchange-2010 × 159
group-policy × 114
windows-server-2012 × 113
wmi × 104
microsoft-office-365 × 100
scheduled-task × 99
iis × 91
windows-server-2016 × 85
winrm × 81
hyper-v × 77
windows-7 × 68
remote-access × 66
permissions × 63
exchange-2013 × 62
dsc × 58
command-line-interface × 57