-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTest SQLPath.ps1
More file actions
56 lines (42 loc) · 1.24 KB
/
Test SQLPath.ps1
File metadata and controls
56 lines (42 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
## create share
$FileShareParams=@{
Name='SQLBackups'
Description='The Place for SQL Backups'
SourceVolume=(Get-Volume-DriveLetterD)
FileServerFriendlyName='$BackupServer'
}
New-FileShare @FileShareParams
## everyone permissions
$FileSharePermsParams=@{
Name = 'SQLBackups'
AccessRight = 'Modify'
AccountName = 'Everyone'}
Grant-FileShareAccess @FileSharePermsParams
## revoke everyone
Revoke-FileShareAccess Name SQLBackups AccountName 'Everyone'
## perms for sql service accounts
$FileSharePermsParams = @{
Name = 'SQLBackups'
AccessRight = 'Modify'
AccountName = 'SQL_DBEngine_Service_Accounts'
}
Grant-FileShareAccess @FileSharePermsParams
## Deny DBA team
$BlockFileShareParams = @{
Name = 'SQLBackups'
AccountName = 'SQL_DBAs_The_Cool_Ones'
}
Block-FileShareAccess @BlockFileShareParams
Get-Help Test-DBASqlPath -Full
## Test one instance
Test-DBaSqlPath -SqlServer sql2016n1 -Path \\BackupServer\SQLBackups
## check numerous instances
$SQLServers = (Get-VM -ComputerName $HyperVServer).Where{$_.Name -like '*SQL*'}.Name
foreach($Server in $SQLServers)
{
$Test = Test-dbaSqlPath -SqlServer $Server -Path '\\BackupServer\SQLBackups'
[PSCustomObject]@{
Server = $Server
Result = $Test
}
}