Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. function New-Share {
  2. param($Path, $Name)
  3. try {
  4. $ErrorActionPreference = 'Stop'
  5. if ( (Test-Path $Path) -eq $false) {
  6. $null = New-Item -Path $Path -ItemType Directory
  7. }
  8. net share $Name=$Path
  9. }
  10. catch {
  11. Write-Warning "Create a new share: Failed, $_"
  12. }
  13. }
  14. To use the new function open up a PowerShell command and type:
  15. PS C:\> New-Share c:\temp TempShare