Get-WMIObject -class win32_physicalmemory | Format-Table devicelocator, capacity –a
This PowerShell command will return the amount of memory in each slot.
Time server MCSE with a BSc degree in engineering. Returning to work after a career break and studying like mad to update my certifications.
Get-WMIObject -class win32_physicalmemory | Format-Table devicelocator, capacity –a
This PowerShell command will return the amount of memory in each slot.
Add-Computer -DomainName Domain01 –Restart
TechNet: PowerShell Add-Computer
Rename-Computer -NewName Server044 -DomainCredential Domain01\Admin01 –Restart
This Solution Accelerator is designed to help enable an organization to identify, classify, and protect data on their file servers. The out-of-the-box classification and rule examples help organizations build and deploy their policies to protect critical information on the file servers in their environment.
PowerShell Script that shuts down all running virtual machines on named Hyper-V server. It shuts them down one at a time waiting while a VM shuts down before shutting down the next. Remember to substitute your <servername>. Quick way to shutdown the test environment at the end of the day.
$runningVM=Get-VM –ComputerName <servername> | Where-Object {$_.State -eq 'Running'}
foreach($cn in $runningVM){
Write-Host "Shutting down $($cn.name)"
stop-vm $cn.name -force
}
Add the following lines to shut down the Hyper-v server
Write-Host "Shutting down Hyper-V server”
Stop-Computer –computername <servername> –force
I have a Virtual Machine that I want to start automatically when I start the Hyper-V server in my test environment. How would I do/undo this with PowerShell.
Start a VM called vm01 automatically
SET-VM –name vm01 –AutomaticStartAction Start
Prevent a VM called vm01 from starting automatically
SET-VM –name Vm01 –AutomaticStartAction Nothing
Wild cards a permissible – every VM that start with b
SET-VM –name b* –AutomaticStartAction Start
Your PowerShell script will not run from the current folder.
If you have myscript.ps1 in c:\myfolder and your current directory is c:\myfolder you will find your script will not run. PowerShell does not search the current folder only those included in the Path variable.
Include the full path c:\myfolder\myscript.ps1 or .\myscript.ps1
the other alternative is to add you folder to the path variable.
When working with a server core I like to have a PowerShell window open. Here is a quick way to do it.
You could just type PowerShell in the cmd window to turn it into a PowerShell window or type Start PowerShell to open a separate PowerShell window.
To have it there waiting for you:
Navigate to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Add string Value called PowerShell with value cmd.exe /k %windir%\system32\WindowsPowerShell\v1.0\powershell.exe
.Alternatively use the PowerShell Command
New-ItemProperty -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\run -Name PowerShell -Value C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -Type string
TechNet: Add a static IP route
route adddestinationmasksubnetmaskgatewaymetriccostmetricifinterface
example #1: route add 10.0.0.0 mask 255.0.0.0 192.168.1.1
by adding this to a workstation you are saying they the route to the 10.0.0.0 network is via gateway 192.168.1.1. This assumes the workstation is on network 192.168.1.0.
This command would result in a temporary route to make it persistent add –p to the command.
example #2: route add 10.0.0.0 mask 255.0.0.0 192.168.1.1 –p
Powershell 4.0:
Get-NetRoute | Format-List -Property *
Rename folder\directory from command line using powershell
rename-item –path ‘c:\oldfoldername’ –newname ‘newfoldername’
“I was working with Hyper-V 2012 R2 free deployment in workgroup configuration and found that I had to change user to the built-in administrator account rather than a created administrator account to successfully run this command.”
Screen Rotation Keyboard Shortcut
Ctrl+Alt+[arrow key]
Quite a common support call