-
Notifications
You must be signed in to change notification settings - Fork 477
Expand file tree
/
Copy pathLinkConvertExample.ps1
More file actions
32 lines (32 loc) · 1.31 KB
/
LinkConvertExample.ps1
File metadata and controls
32 lines (32 loc) · 1.31 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
$output = Get-SQLServerLinkCrawl -Verbose -Username sa -Password 'SuperSecretPassword!' -Instance 'MSSQLSRV04.demo.local\SQLSERVER2014'
$CsvResults = $output |
foreach {
[string]$StringLinkPath = ""
$Path = $_.path
$PathCount = $Path.count - 1
$LinkSrc = $Path[$PathCount - 1]
$LinkDes = $Path[$PathCount]
$LinkUser = $_.user
$LinkDesSysadmin = $_.Sysadmin
$Instance = $_.instance
$LinkDesVersion = $_.Version
$Path |
foreach {
if ( $StringLinkPath -eq ""){
[string]$StringLinkPath = "$_"
}else{
[string]$StringLinkPath = "$StringLinkPath -> $_"
}
}
$Object = New-Object PSObject
$Object | add-member Noteproperty LinkSrc $LinkSrc
$Object | add-member Noteproperty LinkName $LinkDes
$Object | add-member Noteproperty LinkInstance $Instance
$Object | add-member Noteproperty LinkUser $LinkUser
$Object | add-member Noteproperty LinkSysadmin $LinkDesSysadmin
$Object | add-member Noteproperty LinkVersion $LinkDesVersion
$Object | add-member Noteproperty LinkHops $PathCount
$Object | add-member Noteproperty LinkPath $StringLinkPath
$Object
}
$CsvResults | export-csv -NoTypeInformation SQL-Server-Links.csv