efn阿克说 发表于 2018-9-2 11:55:46

powershell 带参数创建共享

  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=$class
  $objwmi.create($folderpath,$shareName,$type,$maxallowed,$description)

页: [1]
查看完整版本: powershell 带参数创建共享