Power Tip of the Day

Create File Shares Remotely
To create a new file share remotely, you could use the WMI class Win32_Share and its Create() method. Invoke-WmiMethod helps you run WMI methods locally and remotely. To create a new share locally or remotely, try this:

###### Start Posh Script ######## 
$Path = 'C:\'
$Name = 'serviceshare'
$Type = 0
$Maximumallowed = 5
$Description = 'PowerShell Share'
$ComputerName = 'storage1'
$rv = Invoke-WmiMethod -Path 'Win32_Share' -ComputerName $ComputerName -Name Create -ArgumentList $null, $Description, $MaximumAllowed, $Name, $null, $Path, $Type
$rv.ReturnValue
###### End Posh Script ######## 

This would create a new share called “serviceshare” on the machine “storage1”. Remove the parameter -ComputerName if you want to run the method locally on your machine. Add the parameter -Credential if you want to run the command remotely with a different identity.
From: http://powershell.com/cs/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s