Showing posts with label -Confirm. Show all posts
Showing posts with label -Confirm. Show all posts

Wednesday, July 25, 2012

Powershell & VMware: "Stopping" running Virtual Machines on VMware server using PowerCLI.

 

Hi,

The one of the main task as a administrator we do is shutting down and powering on the machines :) . Let see how we can stop/shutdown virtual machines using PowerCLI.

Let's Start.

Connected to your VMware VSphere Server first using PowerCLI. ( http://newdelhipowershellusergroup.blogspot.in/2012/07/powershell-vmware-getting-started-with.html )

use Get-VM cmdlet to list all Virtual Machine

25-07-2012 11-40-52

I want to stop/shutdown the virtual machine whose name is "Mrtg-Linux" and you can see the current state of the Virtual machine is "PoweredOn"

we can use Stop-VM cmdlet to stop  virtual machines.  in -VM provide the name of the Virtual machine and it ask you for confirmation type Y and press enter.

Stop-VM -VM Mrtg-Linux

Once you run this cmdlet

25-07-2012 11-59-50

and In case you face RED RED error and not able to STOP Virtual machine :) then use -KiLL Parameter

25-07-2012 12-30-54

Stop-VM -VM Mrtg-Linux  -kill

25-07-2012 12-33-34

Ok, and ok i know , i know you want to suppress the Confirmation isnt ? GEEK

to suppress the confirmation dialogue use -Confirm:$false

Stop-VM -VM Mrtg-Linux  -kill -Confirm:$false

25-07-2012 12-37-06

All Done, Happy :) ?

Thanks for reading.

Thanks!

Aman Dhally

Buy-More-Twitter-Followers 4fb29548b6adc  linkedin

00403skh

Tuesday, May 15, 2012

Powershell and Active Directory: Remove domain user from domain Group using Powershell.

 

Hi,

Today my IT Manager told me to remove a domain user from a specific group. Normally i used "DSA.MSC" or we can say that "Active Directory users and Computers", then i find users, go to his user account properties and click on "Member Of" tab and delete the group which the user is not required.

We can do two things.. Either we can use Get-ADGroupMember cmdlet to find the group  all group member of a particular group,or, we can use Get-ADUser cmdlet to find a group membership of a particular user.

Lets Start.

 Make sure you have "RSAT" installed on you laptop.

Now Import the Active Directory module.

Import-Module ActiveDirectory

30-04-2012 23-21-03 

..

ok, Module is imported,,

Let's use Get-ADUser cmdlet to find group membership of a domain user { http://newdelhipowershellusergroup.blogspot.in/2012/05/powershell-and-active-directory-find_11.html }

$((Get-ADUser Aman.Demo -Properties *).MemberOf -split (",")  | Select-String -SimpleMatch "CN=") -replace "CN=",""

Ok now we know that user "Aman.Demo" is a member of a Fax-Dubai and two others group. Our target is to remove "Aman.Demo" from "Fax-Dubai" Group.

15-05-2012 14-14-18

Let's cross-check if "Fax-Dubai" have a "Aman.Demo" as a member.

Get-ADGroupMember -Identity "Fax-Dubai" | Select-Object Name

Yes it has... Now lets remove "Aman.Demo" from the Group.

15-05-2012 14-28-24

we are Remove-ADGroupMember cmdlet to remove user from the desired Group.

Remove-ADGroupMember -Identity "Fax-Dubai" -Members "Aman.Demo"

before removing the user from the group it ask you for confirmation , type "Y". That's all.

15-05-2012 14-33-44

if you want to suppress Confirmation, you can use -Confirm:$false parameter , after it it wont ask for confirmation.

15-05-2012 14-36-44

ok. now we already removed the user from the group , let's check it now.

User "Aman.Demo" is a member of 2 user groups now previously it was 3, and you can see there is no "Fax-Dubai" exists in Members of now.

15-05-2012 14-39-14

All Sorted :)

Thanks for reading the blog.

Aman Dhally

Aman Dhally