-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModuleStuff.ps1
133 lines (119 loc) · 3.37 KB
/
ModuleStuff.ps1
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# pdate-AllMyModules.ps1
Get-Module -ListAvailable | `
Where-Object {$null -ne $PSItem.RepositorySourceLocation -and $PSItem.ModuleBase -like "$($env:Userprofile)*"} | `
Select-Object -Unique -Property Name | `
Update-Module;
# Remove-OldModules.ps1
Get-Module -ListAvailable | `
Where-Object { $null -ne $PSItem.RepositorySourceLocation -and $PSItem.ModuleBase -like "$($env:Userprofile)*" } | `
Select-Object -Unique -ExpandProperty Name | `
ForEach-Object {
Get-Module -ListAvailable -Name $PSItem | `
Sort-Object -Property Version -Descending | `
Select-Object -Skip 1 | `
foreach-object {
Uninstall-Module -Name $PSItem.Name -RequiredVersion $PSItem.Version
}
}
## Update-AllModules.ps1
Get-Module -ListAvailable | `
Where-Object {$null -ne $PSItem.RepositorySourceLocation} | `
Select-Object -Unique -Property Name | `
Update-Module;
# dbatools-spellcheck.json
"cSpell.enableCompoundWords":true,
"cSpell.userWords": [
"MSSQL",
"Chrissy",
"gmail",
"cmdlet",
"Maire",
"clemaire",
"dbatools",
"computername",
"interop",
"sqlcredential",
"wildcard",
"failover",
"subnet",
"securestring",
"scriptblock",
"verifyonly",
"notin",
"notlike",
"notcontains",
"sqlcollaborative",
"pscustomobject",
"pscmdlet",
"shouldprocess",
"cmdletbinding",
"msdb",
"remoting",
"HKLM",
"machinekey",
"winrm",
"scred",
"dcred",
"netnerds",
"sqlserver",
"sqlcluster",
"filestreams",
"filegroups",
"recurse",
"percentcomplete",
"tempdb",
"SSIS",
"SSISDB",
"Progressbar",
"nvarchar",
"datatable",
"datarow",
"bulkcopy",
"bigint",
"smallint",
"tinyint",
"datetime",
"guid",
"uniqueidentifier",
"wildcard",
"wildcards",
"multiprotocol",
"subnet",
"subnets",
"Updateable",
"OLTP",
"Abshire",
"servername",
"adhoc",
"SSAS",
"endregion",
"parameterclass",
"paramserver",
"notmatch",
"sqlinstance",
"cmdlets",
"ldap",
"contoso",
"ctrlb"
]
#Updated from the Qliq site's PowerShell testing template
Get-Date
$dnsName= "My_DSN_name"
$user="My_User_ID"
$password=""
$csvPath= "C:\temp\OutFileNameForTestingTheDSN.csv"
#$sqlQuery= "select 2 as f1-- * from DB.dbo.Table" #hardcode some SQL
$sqlQuery= Get-Content "C:\temp\TestSQL.txt"
$conn = New-Object Data.Odbc.OdbcConnection
$conn.ConnectionString= "dsn=$dnsName;uid=$user;pwd=$password;"
$conn.open()
$command =$conn.CreateCommand();
$command.CommandText=$sqlQuery
$dataAdapter = New-Object System.Data.Odbc.OdbcDataAdapter $command
$dataTable = new-object "System.Data.DataTable"
$dataAdapter.Fill($dataTable)
$conn.close()
$dataTable | Export-csv -Path $csvPath -NoTypeInformation
Get-Date
Start-Process -FilePath "msiexec.exe" -ArgumentList "/quiet", "/passive", "/qn", "/i", "C:\tools\msodbcsql.msi", "IACCEPTMSODBCSQLLICENSETERMS=YES", "ADDLOCAL=ALL" -Passthru |
Wait-Process. For this to work, I also had to install the Visual C++ Redistributable 2017.