powershell 帶參數建立共享

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)

相關文章
相關標籤/搜索