You might notice oh-my-zsh very slow on WSL2 shell, especially when you cd into a directory with git enabled.
This can be resolved by running following command
git config --global oh-my-zsh.hide-status 1
You might notice oh-my-zsh very slow on WSL2 shell, especially when you cd into a directory with git enabled.
This can be resolved by running following command
git config --global oh-my-zsh.hide-status 1
If you are getting a low disk space alert on a Windows Server, the safest way to free some space is to run the Disk Cleanup wizard. However on Windows Server, by default Disk Cleanup is not installed. Installing it through “Add Windows Features” would trigger a reboot. To avoid this you can simply install it by copying two files cleanmgr.exe and cleanmgr.exe.mui with following commands:
copy C:Windowswinsxsamd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7dacleanmgr.exe %systemroot%System32 copy C:Windowswinsxsamd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63cleanmgr.exe.mui %systemroot%System32en-US
Note: the above commands are for Windows Server 2008 R2. Check this website for other windows versions:
http://technet.microsoft.com/en-us/library/ff630161(WS.10).aspx
For Windows server 2003, PowerShell V1 was released as KB ( hotfix). Download and install KB926139 – Windows PowerShell 1.0 English-Language Installation Package for Windows Server 2003
If you need PowerShell V2, make sure you have SP2 installed and then install Windows Management Framework from http://support.microsoft.com/kb/968929
For Windows Server 2008 run the following command in an elevated Command Prompt.
servermanagercmd -install PowerShell
Windows Server 2008 R2 has PowerShell V2 built in and enabled by default, however, PowerShell ISE is not. It is installed on Windows 7 client OS, but an Optional Component on Windows Server 2008 R2. To Install PowerShell ISE on R2, run the following command in a Windows PowerShell Modules prompt
Import-Module ServerManager
Add-WindowsFeature PowerShell-ISE
OR
Windows Server 2012 has both PowerShell V3 built in and installed. PowerShell ISE needs to be added as it’s an optional Windows PowerShell feature, same as Windows Server 2008 R2.
Also checkout How to run PowerShell scripts to start your first PowerShell script.
SCVMM Cmdlets allow SCVMM admin/users to do everything they can do in SCVMM AdminConsole in windows PowerShell command line. In SCVMM 2008 R2, you can run following command in PowerShell to run SCVMM cmdlets.
Add-PSSnapin Microsoft.SystemCenter.VirtualMachineManager
But this does not work in SCVMM 2012 as SCVMM 2012 uses PowerShell module. For SCVMM 2012 now you need run following in PowerShell instead
Import-Module "C:Program FilesMicrosoft System Center 2012Virtual Machine ManagerbinpsModulesvirtualmachinemanagervirtualmachinemanager"
(This assumes that you have SCVMM 2012 installed on the default location C:Program FilesMicrosoft System Center 2012 )
The PowerShell cmdlets in SCVMM 2012 change a lot in SCVMM 2012, you can get a list of all SCVMM 2012 cmdlets by typing the following at the PowerShell command shell prompt
Get-Command -Module virtualmachinemanager -Type cmdlet
And you can run Get-Help on any of the cmdlets to get the syntax for that cmdlet.
Get-Help <cmdlet name> -detailed
Update: Microsoft has published the SCVMM 2012 cmdlets help to TechNet, check it out http://technet.microsoft.com/en-us/library/hh801697.aspx
You might get following error when you load a snap-in that is written by DotNet 4.0.
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
This is because by default, PowerShell uses DotNet version 2.0 CLR. To use powershell load DotNet 4.0 assemblies, the following settings need to be added in PowerShell.exe.config under C:WindowsSysWOW64WindowsPowerShellv1.0.
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
Note:
PowerShell scripts are text files with ".ps1" extensions that contain PowerShell commands. Starting with Windows Server 2008, PowerShell is built into the OS. For earlier OS versions, you will need to download PowerShell at Microsoft PowerShell Site and install it.
To run ps1 scripts, you first need to enable scripts by running:
Set-ExecutionPolicy RemoteSigned
Otherwise, you will get this error message:
File <script> cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
The most common way to run PowerShell scripts is from Windows PowerShell command prompt. You must specify a path to the script to run it. If the script is in your current folder, then you can run it with:
.script.ps1
If the script is in another folder, you need specify the full path:
c:scriptsscript.ps1
To install PowerShell on Windows Server 2008 R2 or Hyper-V Server 2008 R2, following features needs to be installed.
Because Powershell is built on DotNet framework, DotNet 2.0 and 3.5 has to be installed prior to PowerShell installation.
To install PowerShell from command line, run following from elevated command prompt
DISM.exe /online /enable-feature /featurename:NetFx2-ServerCore DISM.exe /online /enable-feature /featurename:NetFx3-ServerCore DISM.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell
Or run following command if it’s an 64bit machine
DISM.exe /online /enable-feature /featurename:NetFx2-ServerCore-WOW64
DISM.exe /online /enable-feature /featurename:NetFx3-ServerCore-WOW64
DISM.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell-WOW64
To enable DotNet 3.5 from command line, run following from elevated command prompt
dism.exe /online /enable-feature /featurename:NetFx3
This useful command lets you wait for signals from other command windows or even across the network.
waitfor.exe is in windowssystem32 directory.
The simple case for the tool is in one command window you do a “waitfor foobar” and it’ll block until in another window you do a “waitfor /SI foobar”.
powercfg.exe is a windows built in tool to config power management. powercfg.exe is a command line utility, it’s easy to integrate powercfg.exe into scripts.
powercfg -hibernate OFF
powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
powercfg.exe -setabsentia 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c