param($folderPath,$shareName,$maxAllowed=5,$description="BY PowerShell!")
if(!$folderPath)
{
Write-Host "缺少需要共享的目录!";exit
}
if(!$shareName)
{
Write-Host "缺少共享名称!";exit
}
$class="win32_share"
$type=0
if(!(Test-Path $folderPath))
{
New-Item -Path $folderpath -ItemType directory
}
$objwmi=[WmiClass]$class
$objwmi.create($folderpath,$shareName,$type,$maxallowed,$description)
时间: 2025-01-09 08:01:01