Posted by: Preetam | September 23, 2009

xCopy command

xcopy \\Servername\sharename$\%1 c:\%1 /S /E /I
cd \%1

Posted by: Preetam | May 6, 2008

Computer Model Information, Disk Size,

Get-WmiObject -Class win32_computersystemproduct | fl Name,UUID,Identifyingnumber,Vendor

 

Name : IBM eServer BladeCenter HS20 -[86786JX]-
UUID : 30A02FBC-B450-124A-AF23-ECA2279ED40D
Identifyingnumber : KBNY999
Vendor : IBM

———————————–

$LogicalDisks=Get-WmiObject -Class win32_logicaldisk
Foreach($Disk in $logicaldisks) {
if($disk.drivetype -eq “3”) {
$freespace=$Disk.deviceid + ” = {0:N}” -f (($Disk.freespace)/1Gb) + ” GB Free”
$freespace
   }
}

#Result looks like below

C: = 27.77 GB Free
E: = 33.49 GB Free
F: = 39.50 GB Free
G: = 59.79 GB Free
H: = 10.89 GB Free
I: = 11.54 GB Free

Posted by: Preetam | May 5, 2008

PowerShell and Excel

This is script is contributed to Frank Koch who created Free book on Powershell. I learnt how to push excel information only through his book. You may like to go through this book as well. Million thanks to Frank.

http://blogs.msdn.com/powershell/archive/2007/05/11/free-powershell-book.aspx

=====================================================================

#This cmdlet picks the servers from workstations.txt one by one, and collects IP details of each server and pushes them #into excel sheet

$WKSs=get-content Workstations.txt                                #Workstation/Server list
$ExcelSheet=new-object -comobject Excel.application    #Creates excel com object
$WorkBook=$ExcelSheet.WorkBooks.add(1)                       #when you first open excel it creates workbook
$WorkSheet=$WorkBook.WorkSheets.item(1)                    #Under book create a worksheet 
$WorkSheet.cells.item(1,1)=”HostName”                            #Creates first row basically heading
$WorkSheet.cells.item(1,2)=”IPAddress”                            #like hostname,IPAddress,SubnetMask,
$WorkSheet.cells.item(1,3)=”Subnet”                                #Default gateway,DNSDomain,MAC,Description
$WorkSheet.cells.item(1,4)=”Default Gateway”                 #DNSSuffix
$WorkSheet.cells.item(1,5)=”DNSDomain”
$WorkSheet.cells.item(1,6)=”MAC”
$WorkSheet.cells.item(1,7)=”Description”
$WorkSheet.cells.item(1,7)=”DNS Suffix Order”
$i=2

Foreach($WKS in $WKSs) {
$NICCard=Get-WmiObject win32_networkadapterconfiguration -COMPUTER $WKS
foreach($NIC in $NICCard){
if($NIC.ipenabled -eq $true)
{
Write-host Hostname => $NIC.DNSHostName
$WorkSheet.cells.item($i,1)=$NIC.DNSHostName
$WorkSheet.cells.item($i,2)=$NIC.ipaddress
$WorkSheet.cells.item($i,3)=$NIC.IPSubnet
$WorkSheet.cells.item($i,4)=$NIC.DefaultIPGateway
$WorkSheet.cells.item($i,5)=$NIC.DNSDomain
$WorkSheet.cells.item($i,6)=$NIC.MACAddress
$WorkSheet.cells.item($i,7)=$NIC.Description
$WorkSheet.cells.item($i,8)=$NIC.DNSDomainSuffixSearchOrder
$i=$i+1                                                                                      #Remember here you say go to another column
}
}
}
$ExcelSheet.visible=$true

===========================================================================

OutPut in Excel Looks like  

 

image

Posted by: Preetam | May 5, 2008

Re-Fresh to Powershell

image

CODE

$Strg=Read-Host “insert string”
$Strg.toupper()

 


image

CODE

Get-WmiObject -List | where{$_.name -like “win32_B*”}


 

image

CODE

Get-WmiObject win32_bootconfiguration | fl



PS C:\newpowershell> Get-WmiObject -Class win32_share

Name                                    Path                                    Description
—-                                    —-                                    ———–
E$                                      E:\                                     Default share
IPC$                                                                            Remote IPC
G$                                      G:\                                     Default share
F$                                      F:\                                     Default share
ADMIN$                                  C:\WINDOWS                              Remote Admin
C$                                      C:\                                     Default share

PS C:\> Get-Process | Sort-Object -Property cpu -Descending

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
——-  ——    —–      —– —–   ——     — ———–
   1014      24    37572      55504   169   334.98   1652 iexplore
    185       5     3484        284    52   259.27   3144 cidaemon
    295       7     7488       7536    80   172.41   1484 GoogleDesktop
    775       0        0        240     2   157.20      4 System
   1732      38    52464      15512   321   139.72    776 iTunes
    202       5     4248       1328    36    94.80   1720 cisvc
    569      15    20252      12944   104    86.06   1620 explorer
    665       6     2812       3096    28    76.63   1020 csrss
    316       6    51380      39836   175    62.59   2764 powershell
    546      41     9088       7012    82    54.95   1900 GoogleDesktop
    178       7    63896      60572   132    42.08   2380 AcroRd32
    192       7    43384      45640   116    32.53    252 rtvscan
     81       3     1672       5752    37    25.39   1868 Apoint
   1851      66    16828      25680   108    17.11    208 svchost
     41       2      916       2908    29    12.94   1600 ApntEx
    502      11     4688        760    44    10.77   1100 lsass
    317       7     1836       4608    23     9.73   1088 services
    410      14     2036       4644    38     6.88   1320 svchost
    113       3     1400       3576    25     6.72    404 igfxsrvc
    422      40     5932       2236    50     6.41   1044 winlogon
    122       5     2884       6752    51     4.55    344 BATTER~1
    210       6    13336      19532    67     3.22   1936 vmware-tray
    432      13    10852      19740    89     2.52   3616 googletalk
    139       5     3544       5340    46     2.28   1240 spoolsv
    143       6     1040       4304    37     2.19   2024 ctfmon
    157       5     3972       6676    47     1.86   1876 quickset
    199       5     3152       5060    63     1.72   1272 svchost
    124       4     1636       5720    46     1.33   1980 EverioService
    209       6     1748       4448    38     1.31    440 svchost
    103       5     1164       3572    32     1.31   3488 alg
     91       4     1548       3668    30     1.06    296 svchost
    120       4     3552       5528    41     0.84   1916 NicConfigSvc
    279       6     6460       8964   201     0.63   3232 iTunesHelper
    123       4     2456       4260    36     0.61   1164 svchost
    110       4     2440       4080    37     0.55   1884 vptray
    105       4    17004      12292    52     0.47   1908 AppleMobileDeviceHelper
    128       4     2464       4052    35     0.44   3496 iPodService
     89       3      760       2920    23     0.42   1848 hkcmd
    144       4     1820       5084    37     0.38   2952 wmiprvse
    162       5     2472       5204    45     0.38    792 rapimgr
    145       6     1392       4988    45     0.36    228 wcescomm
     52       2     1736       2500    24     0.33   1536 hidfind
    103       3      760       3080    24     0.31   1856 igfxpers
     58       3     2024       4520    38     0.27   1956 hqtray
     32       2     2040       2792    30     0.27   3596 cmd
     21       1      168        388     4     0.25    936 smss
     34       2      792       3256    32     0.23    512 wweb32
     92      19     1256       2876    30     0.20   2328 MSGSYS
     72       5     1644       2232    16     0.16   1988 AppleMobileDeviceService
     85       3      840       2920    34     0.11    856 RichVideo
     36       2    10036       4456    37     0.11    488 distnoted
     28       1      436       1516    17     0.09   1736 defwatch
     78       5     1120       3032    27     0.08    428 XFR
     58       3     1172       2852    26     0.08   1804 PDS
      0       0        0         28     0               0 Idle

PS C:\> Get-Process | Sort-Object -Property cpu -Descending | Select-Object -First 10

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
——-  ——    —–      —– —–   ——     — ———–
   1010      24    37444       6716   167   336.31   1652 iexplore
    184       5     3432        296    52   261.44   3144 cidaemon
    294       7     7348       3964    80   234.19   1484 GoogleDesktop
    774       0        0        240     2   158.14      4 System
   1732      38    52464      15688   321   139.81    776 iTunes
    202       5     4248       1956    36    96.47   1720 cisvc
    571      15    20296      13928   105    92.22   1620 explorer
    688       7     2784       2052    28    83.64   1020 csrss
    418       6    51936      12184   175    64.17   2764 powershell
    547      41     8468       6880    84    56.02   1900 GoogleDesktop

Posted by: Preetam | March 20, 2008

PS C:\> get-help out-* | Format-List name,synopsis

PS C:\> get-help out-* | Format-List name,synopsis

Name     : Out-Null
Synopsis : Deletes output instead of sending it to the console.

Name     : Out-Default
Synopsis : Send the output to the default formatter and the default output cmdlet. This cmdlet has no effect on the formatting  or output. It is a placeholder that lets you write your own Out-Default function or cmdlet.

Name     : Out-Host
Synopsis : Sends output to the command line.

Name     : Out-File
Synopsis : Sends output to a file.

Name     : Out-Printer
Synopsis : Sends output to a printer.

Name     : Out-String
Synopsis : Sends objects to the host as a series of strings.

Posted by: Preetam | March 20, 2008

Get-Service | Sort-Object status -des

Status   Name               DisplayName                          
——   —-               ———–                          
Running  RasMan             Remote Access Connection Manager     
Running  RichVideo          Cyberlink RichVideo Service(CRVS)    
Running  PolicyAgent        IPSEC Services                       
Running  ProtectedStorage   Protected Storage                    
Running  Schedule           Task Scheduler                       
Running  seclogon           Secondary Logon                      
Running  RpcSs              Remote Procedure Call (RPC)          
Running  SamSs              Security Accounts Manager            
Running  LmHosts            TCP/IP NetBIOS Helper                
Running  Netman             Network Connections                  
Running  lanmanserver       Server                               
Running  lanmanworkstation  Workstation                          
Running  Norton AntiViru… Norton AntiVirus Client              
Running  PlugPlay           Plug and Play                        
Running  NICCONFIGSVC       NICCONFIGSVC                         
Running  Nla                Network Location Awareness (NLA)     
Running  SENS               System Event Notification            
Running  W32Time            Windows Time                         
Running  WebClient          WebClient                            
Running  Themes             Themes                               
Running  TrkWks             Distributed Link Tracking Client     
Running  wuauserv           Automatic Updates                    
Running  WZCSVC             Wireless Zero Configuration          
Running  winmgmt            Windows Management Instrumentation   
Running  wscsvc             Security Center                      
Running  Spooler            Print Spooler                        
Running  srservice          System Restore Service               
Running  SharedAccess       Windows Firewall/Internet Connectio…
Running  ShellHWDetection   Shell Hardware Detection             
Running  TapiSrv            Telephony                            
Running  TermService        Terminal Services                    
Running  SSDPSRV            SSDP Discovery Service               
Running  stisvc             Windows Image Acquisition (WIA)      
Running  Eventlog           Event Log                            
Running  ERSvc              Error Reporting Service              
Running  Dnscache           DNS Client                           
Running  AudioSrv           Windows Audio                        
Running  FastUserSwitchi… Fast User Switching Compatibility    
Running  EventSystem        COM+ Event System                    
Running  BITS               Background Intelligent Transfer Ser…
Running  DefWatch           DefWatch                             
Running  DcomLaunch         DCOM Server Process Launcher         
Running  CryptSvc           Cryptographic Services               
Running  Browser            Computer Browser                     
Running  CiSvc              Indexing Service                     
Running  Dhcp               DHCP Client                          
Running  helpsvc            Help and Support                     
Running  Intel PDS          Intel PDS                            
Running  Intel File Tran… Intel File Transfer                  
Running  ALG                Application Layer Gateway Service    
Running  iPod Service       iPod Service                         
Running  Apple Mobile De… Apple Mobile Device                  
Running  HidServ            HID Input Service                    
Stopped  BlueSoleil Hid … BlueSoleil Hid Service               
Stopped  upnphost           Universal Plug and Play Device Host  
Stopped  ufad-ws60          VMware Agent Service                 
Stopped  SysmonLog          Performance Logs and Alerts          
Stopped  SwPrv              MS Software Shadow Copy Provider     
Stopped  xmlprov            Network Provisioning Service         
Stopped  WudfSvc            Windows Driver Foundation – User-mo…
Stopped  Alerter            Alerter                              
Stopped  VMware NAT Service VMware NAT Service                   
Stopped  vmount2            VMware Virtual Mount Manager Extended
Stopped  WLSetupSvc         Windows Live Setup Service           
Stopped  AppMgmt            Application Management               
Stopped  aspnet_state       ASP.NET State Service                
Stopped  VSS                Volume Shadow Copy                   
Stopped  VMnetDHCP          VMware DHCP Service                  
Stopped  WmiApSrv           WMI Performance Adapter              
Stopped  UPS                Uninterruptible Power Supply         
Stopped  WMPNetworkSvc      Windows Media Player Network Sharin…
Stopped  WmdmPmSN           Portable Media Serial Number Service 
Stopped  VMAuthdService     VMware Authorization Service         
Stopped  usnjsvc            Messenger Sharing Folders USN Journ…
Stopped  ClipSrv            ClipBook                             
Stopped  NtLmSsp            NT LM Security Support Provider      
Stopped  HTTPFilter         HTTP SSL                             
Stopped  ImapiService       IMAPI CD-Burning COM Service         
Stopped  gusvc              Google Updater Service               
Stopped  ose                Office Source Engine                 
Stopped  NtmsSvc            Removable Storage                    
Stopped  Netlogon           Net Logon                            
Stopped  MSDTC              Distributed Transaction Coordinator  
Stopped  mnmsrvc            NetMeeting Remote Desktop Sharing    
Stopped  Messenger          Messenger                            
Stopped  NetDDEdsdm         Network DDE DSDM                     
Stopped  NetDDE             Network DDE                          
Stopped  MSIServer          Windows Installer                    
Stopped  Pml Driver HPZ12   Pml Driver HPZ12                     
Stopped  sdCoreService      PC Tools Security Service            
Stopped  sdAuxService       PC Tools Auxiliary Service           
Stopped  dmserver           Logical Disk Manager                 
Stopped  clr_optimizatio… .NET Runtime Optimization Service v…
Stopped  COMSysApp          COM+ System Application              
Stopped  dmadmin            Logical Disk Manager Administrative…
Stopped  SCardSvr           Smart Card                           
Stopped  RDSessMgr          Remote Desktop Help Session Manager  
Stopped  RasAuto            Remote Access Auto Connection Manager
Stopped  GoogleDesktopMa… Google Desktop Manager 5.5.709.30344 
Stopped  RSVP               QoS RSVP                             
Stopped  RpcLocator         Remote Procedure Call (RPC) Locator  
Stopped  RemoteAccess       Routing and Remote Access            

Remote Access Connection Manager ==> Running
Cyberlink RichVideo Service(CRVS) ==> Running
IPSEC Services ==> Running
Protected Storage ==> Running
Task Scheduler ==> Running
Secondary Logon ==> Running
Remote Procedure Call (RPC) ==> Running
Security Accounts Manager ==> Running
TCP/IP NetBIOS Helper ==> Running
Network Connections ==> Running
Server ==> Running
Workstation ==> Running
Norton AntiVirus Client ==> Running
Plug and Play ==> Running
NICCONFIGSVC ==> Running
Network Location Awareness (NLA) ==> Running
System Event Notification ==> Running
Windows Time ==> Running
WebClient ==> Running
Themes ==> Running
Distributed Link Tracking Client ==> Running
Automatic Updates ==> Running
Wireless Zero Configuration ==> Running
Windows Management Instrumentation ==> Running
Security Center ==> Running
Print Spooler ==> Running
System Restore Service ==> Running
Windows Firewall/Internet Connection Sharing (ICS) ==> Running
Shell Hardware Detection ==> Running
Telephony ==> Running
Terminal Services ==> Running
SSDP Discovery Service ==> Running
Windows Image Acquisition (WIA) ==> Running
Event Log ==> Running
Error Reporting Service ==> Running
DNS Client ==> Running
Windows Audio ==> Running
Fast User Switching Compatibility ==> Running
COM+ Event System ==> Running
Background Intelligent Transfer Service ==> Running
DefWatch ==> Running
DCOM Server Process Launcher ==> Running
Cryptographic Services ==> Running
Computer Browser ==> Running
Indexing Service ==> Running
DHCP Client ==> Running
Help and Support ==> Running
Intel PDS ==> Running
Intel File Transfer ==> Running
Application Layer Gateway Service ==> Running
iPod Service ==> Running
Apple Mobile Device ==> Running
HID Input Service ==> Running
BlueSoleil Hid Service ==> Stopped
Universal Plug and Play Device Host ==> Stopped
VMware Agent Service ==> Stopped
Performance Logs and Alerts ==> Stopped
MS Software Shadow Copy Provider ==> Stopped
Network Provisioning Service ==> Stopped
Windows Driver Foundation – User-mode Driver Framework ==> Stopped
Alerter ==> Stopped
VMware NAT Service ==> Stopped
VMware Virtual Mount Manager Extended ==> Stopped
Windows Live Setup Service ==> Stopped
Application Management ==> Stopped
ASP.NET State Service ==> Stopped
Volume Shadow Copy ==> Stopped
VMware DHCP Service ==> Stopped
WMI Performance Adapter ==> Stopped
Uninterruptible Power Supply ==> Stopped
Windows Media Player Network Sharing Service ==> Stopped
Portable Media Serial Number Service ==> Stopped
VMware Authorization Service ==> Stopped
Messenger Sharing Folders USN Journal Reader service ==> Stopped
ClipBook ==> Stopped
NT LM Security Support Provider ==> Stopped
HTTP SSL ==> Stopped
IMAPI CD-Burning COM Service ==> Stopped
Google Updater Service ==> Stopped
Office Source Engine ==> Stopped
Removable Storage ==> Stopped
Net Logon ==> Stopped
Distributed Transaction Coordinator ==> Stopped
NetMeeting Remote Desktop Sharing ==> Stopped
Messenger ==> Stopped
Network DDE DSDM ==> Stopped
Network DDE ==> Stopped
Windows Installer ==> Stopped
Pml Driver HPZ12 ==> Stopped
PC Tools Security Service ==> Stopped
PC Tools Auxiliary Service ==> Stopped
Logical Disk Manager ==> Stopped
.NET Runtime Optimization Service v2.0.50727_X86 ==> Stopped
COM+ System Application ==> Stopped
Logical Disk Manager Administrative Service ==> Stopped
Smart Card ==> Stopped
Remote Desktop Help Session Manager ==> Stopped
Remote Access Auto Connection Manager ==> Stopped
Google Desktop Manager 5.5.709.30344 ==> Stopped
QoS RSVP ==> Stopped
Remote Procedure Call (RPC) Locator ==> Stopped
Routing and Remote Access ==> Stopped

Apologies for Windows XP Screen shot. I’m still smart person and Don’t wish to buy Hardware for VISTA

 

image

Older Posts »

Categories

Follow

Get every new post delivered to your Inbox.