Create Shared folder
Function New-SharedFolder ($FolderPath, $Sharename)
{
# Test for existence of folder, if not there then create it
IF (!(Test-Path $FolderPath)) {
new-item $FolderPath -type Directory }
# Create Share but check to make sure it isn’t already there
$Shares=[WMICLASS]”WIN32_Share”
if(!$Sharename) {
$Sharename = Split-Path $FolderPath -Leaf
}
If (!(Get-WmiObject Win32_Share | where {$_.Name -eq $Sharename})) {
$Shares.Create($FolderPath,$Sharename,0)
}
}
#Creates 'c:\xxx' shared folder for everyone with 'xxx' name
New-SharedFolder "c:\xxx"