Memory And CPU Check Script


Today I have created one powershell script which is useful to diagnose high CPU and Memory Consumption on Windows Server..



#Memory And CPU Check Script by Prashant SHalgar; 2014#

        $scripthost = Read-Host 'Enter 1 for Memory or 2 for CPU';
        "Server Diagnostics"
        if ($scripthost -match "1")

            #Memory and CPU Check Script by Prashant Shalgar#

#Top 10 Processes using Physical Memory #

"The Top 10 Processes using Physical Memory are:"

Get-Process | Sort-Object -Property "WS" -desc | Select-Object -First 15
#Total and Available Physical Memory"
systeminfo | findstr "Memory"

($scripthost -match "2")
{  #Top 10 Processes using CPU #

echo "The Top 10 Processes using CPU are:"

Get-Process | Sort-Object -Property "CPU" -desc | Select-Object -First 15
" "
"#Load On CPU"
Get-WmiObject win32_processor | select LoadPercentage

Get-WmiObject win32_processor | Measure-Object -property LoadPercentage -Average -maximum -minimum | Select

  Write-Host -BackgroundColor White -ForegroundColor Red "INVALID ENTRY! Please try again."


 "#All User Sessions On This Server"
query session

Read-Host -Prompt "Press Enter to exit"


Sunday by Prashant Shalgar · 0


Configuring Windows Server Core 2012 Part 2

Configuring Basic Settings
  1. Connect with server core using Remote desktop Connection.
  1. Type "netsh int ipv4 show address to view current ip address of server" to view the adepter name and IP adress.

To configure basic setting in server core we have use some commands,e.g to configure network adapter settings we have to use netsh, and to rename or to join computer in domain we have use netdom, below is step by step procedure which will help to configure you core server.

  1. To change ip address we have fire "netsh int ipv4 set address name=Ethernet source=staic address= mask= gateway=",you might get disconnect if you had taken RDP session, so connect again to server by new IP.
  2. To added or change DNS server settings Type"netsh int ipv4 add dnsservers "Eternet(Name of Network Adapder)" of DNS Server)
  3. And now to verify that will type ipconfig/all
  4. To view ComputerName type "hostname" or "Set".And to change Computer Name Type "netdom renamecomputer %computername% /newname:Win-WSUS /userd:administrator /passwordd:<EnterPassword> /reboot:0"


Type sconfig

001-StartSConfigThe first thing I always do, is change the computer name of my server. To do this, enter 2 and hit enter. It will now ask for the new computer name, enter your computer name and hit enter.A popup will appear asking you if you want to reboot, click No, since we also want to change the IP configuration now.
002-RenameComputerYou will go back to the main menu automatically. No to change the IP address of this server, use option 8 and hit enter. A list of available adapters will be displayed (in my case, I only have one virtual NIC in my machine).
003-IPConfigEnter the number which is in front of the adapter you want to change and hit enter. The menu will display a sub-menu with the current configuration and options to change your adapter settings.
004-IPAdapterSelectedNow to change the IP address, enter option 1 and hit enter. SConfig will ask you if you want to configure this adapter to use DHCP or a static IP. In this example, I’m using a static IP, so enter s and hit enter. Next, sconfig will ask you for the IP address, subnet mask and default gateway. Just enter the information.
005-SetIPNext is to configure the DNS server. Select option 2 and enter the IP of your DNS server. A popup will appear telling you that the DNS server has been set.
006-DNSSetSconfig will ask you for a secondary DNS server. In this example, I’m just using one DNS server, so just hit enter to leave it empty. After this, you will return in the network adapter configuration again.
006-DNSSetDoneTo return to the main menu, enter option 4 and hit enter. Now we want to reboot this server. This would be option number 13. Sconfig will ask you if you are sure, press Yes.
007-RebootAfter the server has been rebooted, log in using your Administrator credentials again and start sconfig. Now to join the domain, enter option 1. Sconfig will ask you if you want to join a domain or a workgroup, enter option D and hit enter. Enter the name of your domain and hit enter. Next, sconfig will ask for an account which is authorized to join this machine to the domain. Enter an account with correct permissions and hit enter. Now sconfig will ask for the password for that account, enter it and hit enter. The next question is if we want to change the computer name before you join this machine to the domain. Since we already changed the computer name at the beginning, click No.
008-JoinDomainNow the machine is joined to the domain, reboot the machine and you’re done!

Thats all in Part 2

Thanks For reading..

Tuesday by Prashant Shalgar · 0

Windows Admin Jobs in Pune