→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎10-07-2020 03:47 PM
$HostName = hostname
$startdatetime = Get-Date -format "yyyyMMddHHmmss"
$TranscriptFile = -join("\\thepcname\PowershellRedirection\","Get-ODBC_DSNs",$StartDateTime,$hostname,".txt")
#ODBC DSN list before
get-odbcdsn | select-object name *> $TranscriptFile
$HostName = hostname
$startdatetime = Get-Date -format "yyyyMMddHHmmss"
$TranscriptFile = -join("\\server\PowershellRedirection\","ODBC_DSN_Install",$StartDateTime,$hostname,".txt")
#ODBC DSN list before
get-odbcdsn | select-object name *> $TranscriptFile
#A1
If($HostName -eq "computera") -or ($HostName -eq "computerb") -or ($HostName -eq "computerc"){
Add-OdbcDsn -Name "ODBCDSN1" -DriverName "ODBC Driver 17 for SQL Server" -DsnType "System" -Platform "32-bit" -SetPropertyValue @("Server=dbserver2", "Trusted_Connection=Yes", "Database=db2", "Description=Driver Version 17 32-bit System DSN Type") -PassThru *>> $TranscriptFile
}
#A1 and A2
If($HostName -eq "computerc") -or ($HostName -eq "computerb") -or ($HostName -eq "computerd") -or ($HostName -eq "computere") -or ($HostName -eq "computerf"){
Add-OdbcDsn -Name "ODBCDSN2" -DriverName "ODBC Driver 17 for SQL Server" -DsnType "System" -Platform "32-bit" -SetPropertyValue @("Server=dbserver2", "Trusted_Connection=Yes", "Database=db3", "Description=Driver Version 17 32-bit System DSN Type") -PassThru *>> $TranscriptFile
Add-OdbcDsn -Name "ODBCDSN3" -DriverName "ODBC Driver 17 for SQL Server" -DsnType "System" -Platform "32-bit" -SetPropertyValue @("Server=dbserver2", "Trusted_Connection=Yes", "Database=db4", "Description=Driver Version 17 32-bit System DSN Type") -PassThru *>> $TranscriptFile
Add-OdbcDsn -Name "ODBCDSN4" -DriverName "ODBC Driver 17 for SQL Server" -DsnType "System" -Platform "32-bit" -SetPropertyValue @("Server=dbserver2", "Trusted_Connection=Yes", "Database=db5", "Description=Driver Version 17 32-bit System DSN Type") -PassThru *>> $TranscriptFile
Add-OdbcDsn -Name "ODBCDSN5" -DriverName "ODBC Driver 17 for SQL Server" -DsnType "System" -Platform "32-bit" -SetPropertyValue @("Server=dbserver2", "Trusted_Connection=Yes", "Database=db6", "Description=Driver Version 17 32-bit System DSN Type") -PassThru *>> $TranscriptFile
Add-OdbcDsn -Name "ODBCDSN6" -DriverName "ODBC Driver 17 for SQL Server" -DsnType "System" -Platform "32-bit" -SetPropertyValue @("Server=dbserver2", "Trusted_Connection=Yes", "Database=db7", "Description=Driver Version 17 32-bit System DSN Type") -PassThru *>> $TranscriptFile
Add-OdbcDsn -Name "ODBCDSN7" -DriverName "ODBC Driver 17 for SQL Server" -DsnType "System" -Platform "32-bit" -SetPropertyValue @("Server=dbserver2", "Trusted_Connection=Yes", "Database=db8", "Description=Driver Version 17 32-bit System DSN Type") -PassThru *>> $TranscriptFile
}
#ODBC DSN list after
get-odbcdsn | select-object name *>> $TranscriptFile
‎10-08-2020 02:46 PM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now