Created
May 5, 2020 14:23
-
-
Save alx9r/a1c6d140db59e105d17325e46255689d to your computer and use it in GitHub Desktop.
x-OdbcDsn workarounds (PowerShell/PowerShell#12427)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get | |
Invoke-CimMethod -ClassName MSFT_OdbcDsnTask ` | |
-Namespace ROOT\Microsoft\Windows\Wdac ` | |
-MethodName 'Get' ` | |
-Arguments @{ | |
Name = $Name | |
DsnType = [string]$DsnType | |
Platform = $Platform | |
DriverName = $DriverName | |
} | |
# Add DSN | |
Invoke-CimMethod -ClassName MSFT_OdbcDsnTask ` | |
-Namespace ROOT\Microsoft\Windows\Wdac ` | |
-MethodName 'Add' ` | |
-Arguments @{ | |
Name = $Name | |
DsnType = [string]$DsnType | |
Platform = $Platform | |
DriverName = $DriverName | |
} | |
# Remove DSN | |
Invoke-CimMethod -ClassName MSFT_OdbcDsnTask ` | |
-Namespace ROOT\Microsoft\Windows\Wdac ` | |
-MethodName 'RemoveByName' ` | |
-Arguments @{ | |
Name = $Name | |
DsnType = [string]$DsnType | |
Platform = $Platform | |
DriverName = $DriverName | |
} | |
# Set DSN Property | |
Invoke-CimMethod -ClassName MSFT_OdbcDsnTask ` | |
-Namespace ROOT\Microsoft\Windows\Wdac ` | |
-MethodName 'SetByName' ` | |
-Arguments @{ | |
Name = $Name | |
DsnType = [string]$DsnType | |
Platform = $Platform | |
DriverName = $DriverName | |
SetPropertyValue = ,"$Key=$Value" | |
} | |
# Remove DSN Property | |
Invoke-CimMethod -ClassName MSFT_OdbcDsnTask ` | |
-Namespace ROOT\Microsoft\Windows\Wdac ` | |
-MethodName 'SetByName' ` | |
-Arguments @{ | |
Name = $Name | |
DsnType = [string]$DsnType | |
Platform = $Platform | |
DriverName = $DriverName | |
RemovePropertyValue = ,$Key | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment