Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. powershell_script 'setup SQL mountpoints' do
  2. code <<-EOH
  3. Function Create-MountPoint
  4. {
  5. [cmdletbinding(SupportsShouldProcess=$true)]
  6. param([string[]]$Name,[int]$diskNumber,[int]$PartitionNumber =2,$FolderPath ="C:/SAN" )
  7.  
  8. Process
  9. {
  10. if ($pscmdlet.ShouldProcess("$FolderPath/$name", "Creating Mountpoint"))
  11. {
  12. If (-not (test-path "$FolderPath/$name")){
  13. New-Item -ItemType Directory -Path "$FolderPath/$name"
  14. Get-Disk -Number $diskNumber | Initialize-Disk -PartitionStyle GPT
  15. New-Partition -Disknumber $diskNumber -UseMaximumSize
  16. Add-PartitionAccessPath -Disknumber $diskNumber -PartitionNumber $PartitionNumber -AccessPath "$FolderPath/$name/" -passthru
  17. Get-Partition -Disknumber $diskNumber -PartitionNumber $PartitionNumber | Format-Volume -FileSystem NTFS -Confirm:$False
  18. }
  19. else
  20. {Write-host "$FolderPath/$name already exists"}
  21. }
  22. }
  23.  
  24. }
  25.  
  26.  
  27. if ((Test-Path C:/SAN))
  28. {
  29.  
  30. $path = @( "DATA","LOG","TEMPDB_LOG","TEMPDB_DATA" )
  31. (1..$path.count) | ForEach {
  32. $index = $_ - 1
  33. Create-MountPoint -Name $Path[$index] -diskNumber $_ -FolderPath "C:/temp" -WhatIf
  34. }
  35.  
  36. }
  37. EOH
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement