param($folderPath,$shareName,$maxAllowed=5,$description="BY PowerShell!")ide
if(!$folderPath)ip
{it
Write-Host "缺乏须要共享的目录!";exitio
}class
if(!$shareName)di
{view
Write-Host "缺乏共享名称!";exitvi
}co
$class="win32_share"editor
$type=0
if(!(Test-Path $folderPath))
{
New-Item -Path $folderpath -ItemType directory
}
$objwmi=[WmiClass]$class
$objwmi.create($folderpath,$shareName,$type,$maxallowed,$description)