Posts

Important Vcenter Appliance CLI commands

Image
vCenter Server services  running status can be checked  using this command service-control --status --all It Should return the result as depicted below:

Running CLI Commands in ESXi using plink software

Image
Get-esxcli will help us to run the CLI commands over the host directly but to extend it we cannot run certain commands directly over the host, In such case, we can use the below script to run directly on the host and achieve our goals. One shot with the script to achieve multiple targets My target was given to check the status of smartd services in each host and disable it, So I have put the commands on the variable $cmd and $cmd2 and executing it in all the machines,  which has been feed in the variable $machines , command get executed in all the hosts fed in the variable $machines . Script :  $user = '' $pswd = '' $cmd = 'etc/init.d/smartd status' $cmd2 = 'chkconfig smartd off' $machines = Get-Content "" foreach ( $MACHINE in $machines ) { Get-VMHost -Name $MACHINE | % {     $ssh = Get-VMHostService -VMHost $_ | where { $_ . Key -eq 'TSM-SSH' }     if ( ! $ssh . Running)

How to reset the IE settings Through command Line (CMD)

Image
I was just wondering that how to reset the IE personal settings through command line as I am much more interested over the cli functions, just got this command to reset the settings of the IE to the default one. rundll32 inetcpl.cpl ResetIEtoDefaults Run the above code by pressing the (windows key + R), Just type the above command and you will get the below prompt. just select the checkbox and click reset button all is done.

Default powershell commands not getting executed , getting command not recognized.

I was working on some weird cases that some of the basic powershell commands are not getting  executed in the machine and i came to know that the powershell modules are not getting loaded due to which default modules are not getting loaded in the psmodule path. Resolution would be to run the below commands: $PSModulePath = Get-ItemProperty -Path "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "PSModulePath" $newPSModulePath = $PSModulePath.PSModulePath + ";C:\Windows\System32\WindowsPowerShell\v1.0\Modules" Set-ItemProperty -Path "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "PSModulePath" -value $newPSModulePath Else you need to create a PSModulePath value under the below path : HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment and need to enter the value of path mentioned below in the PSModulePath key : %SystemRoot%\system32\WindowsPowerShell\v1.0\M

How to extract msu/msp/msi/exe files from the command line

We can use the below commands to extract and execute the msu/msp/msi/exe files through cli mode.   Microsoft Hotfix Installer (.exe) setup.exe /t:C: /c Microsoft Update Standalone Package (.msu) expand -F:* update.msu C: cd expand -F:* update.cab C: Microsoft Patch File (.msp) msix patch.msp /out C: msix.zip Windows Installer Package (.msi) msiexec /a setup.msi /qb TARGETDIR=C:

Fetch the List of RDMs Attached in the machine using Powercli

Image
I used to maintain a powercli toolkit to ensure all the redundant tasks which ever to be performed can be automated in the proper way without affecting the running environment. I am sharing a script which comes in handy when you need to identify the list of RDMs attached to the virtual machines in the cluster Get-Cluster | Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName | Export-csv -notypeinformation -path "c:\RDMattachedmachine" => Indicates that you have to put the cluster name in the space and execute the command. This command has been tested under vcenter 5.5 and 6.0.  Run with care in the production environment and happy scripting. Kindly put your comments and queries below.

Auto creation and deletion of Snapshots in Vsphere Environment using Powercli

Image
Today we are gonna develop a script that will automatically delete multiple snapshots that has been taken in VMs running in the Vsphere environment. We use powercli to create the script and run over the vcenter where the VMs are hosted Before we go ahead, I would like to share you a small brief on what is powercli, powercli is a command-line interface (CLI) tool for automating vSphere and vCloud management. VMware vSphere PowerCLI debuted as the VMware Infrastructure Toolkit, also called the VI Toolkit. We have created two machine named test-vigneshbabu, test1-vigneshbabu as shown below: Now we are gonna trigger a script that will take the snapshot of these machines as “before patching” as shown below, You can customise the name of the snapshots according to your standards. Code : $servers = Get-Content "c:\vm-serverslist.txt" foreach ( $i in $servers ) {  New-Snapshot -VM $i -Name before_pathing } Note: path of the get-content is customisable and it’s the file