Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- powershell_script 'setup SQL mountpoints' do
- code <<-EOH
- Function Create-MountPoint
- {
- [cmdletbinding(SupportsShouldProcess=$true)]
- param([string[]]$Name,[int]$diskNumber,[int]$PartitionNumber =2,$FolderPath ="C:/SAN" )
- Process
- {
- if ($pscmdlet.ShouldProcess("$FolderPath/$name", "Creating Mountpoint"))
- {
- If (-not (test-path "$FolderPath/$name")){
- New-Item -ItemType Directory -Path "$FolderPath/$name"
- Get-Disk -Number $diskNumber | Initialize-Disk -PartitionStyle GPT
- New-Partition -Disknumber $diskNumber -UseMaximumSize
- Add-PartitionAccessPath -Disknumber $diskNumber -PartitionNumber $PartitionNumber -AccessPath "$FolderPath/$name/" -passthru
- Get-Partition -Disknumber $diskNumber -PartitionNumber $PartitionNumber | Format-Volume -FileSystem NTFS -Confirm:$False
- }
- else
- {Write-host "$FolderPath/$name already exists"}
- }
- }
- }
- if ((Test-Path C:/SAN))
- {
- $path = @( "DATA","LOG","TEMPDB_LOG","TEMPDB_DATA" )
- (1..$path.count) | ForEach {
- $index = $_ - 1
- Create-MountPoint -Name $Path[$index] -diskNumber $_ -FolderPath "C:/temp" -WhatIf
- }
- }
- EOH
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement