Skip to content

Commit e7ab7f7

Browse files
A commit
1 parent d3afb28 commit e7ab7f7

File tree

3 files changed

+85
-6
lines changed

3 files changed

+85
-6
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Contains useful functions that I use and am able to share.
1212
[When-WillSQLComplete](When-WillSQLComplete.ps1) - Quick function to check progress of SQL Commands via sys.dm_exec_requests. Useful for DBCC, Backup, Restore and indexing progress
1313

1414
[Test-OLAInstance](Test-OLAInstance.ps1) - Wrapper to call a Pester Test script [Test-OLA](Test-OLA.ps1) to test Ola Hallengren Maintenance Solution is installed correctly
15+

Snippets List.ps1

+24-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
## A list of snippets
2-
2+
$snips = Get-IseSnippet
33
# Create a new snippet snippet!
44

5+
if(!$snips.Where{$_.Name -like 'New-Snippet*'})
6+
{
57
$snippet1 = @{
68
Title = 'New-Snippet'
79
Description = 'Create a New Snippet'
@@ -17,9 +19,10 @@ New-IseSnippet @snippet
1719
"@
1820
}
1921
New-IseSnippet @snippet1 –Force
20-
22+
}
2123
# SMO Snippet
22-
24+
if(!$snips.Where{$_.Name -like 'SMO-Server*'})
25+
{
2326
$snippet = @{
2427
Title = 'SMO-Server'
2528
Description = 'Creates a SQL Server SMO Object'
@@ -28,9 +31,10 @@ $snippet = @{
2831
"@
2932
}
3033
New-IseSnippet @snippet
31-
34+
}
3235
## Data table snippet
33-
36+
if(!$snips.Where{$_.Name -like 'New-DataTable*'})
37+
{
3438
$snippet = @{
3539
Title = 'New-DataTable'
3640
Description = 'Creates a Data Table Object'
@@ -58,7 +62,11 @@ $snippet = @{
5862
"@
5963
}
6064
New-IseSnippet @snippet
65+
}
66+
6167
#formatted duration snippet
68+
if(!$snips.Where{$_.Name -like 'Formatted Duration*'})
69+
{
6270
$snippet = @{
6371
Title = 'Formatted Duration'
6472
Description = 'Formats Get-SQLAgentJobHistory into timespan'
@@ -72,7 +80,10 @@ $snippet = @{
7280
"@
7381
}
7482
New-IseSnippet @snippet
83+
}
7584

85+
if(!$snips.Where{$_.Name -like 'Prompt for*'})
86+
{
7687
$snippet = @{
7788
Title = 'Prompt for input'
7889
Description = 'Simple way of gathering input from users with simple yes and no'
@@ -92,7 +103,10 @@ $snippet = @{
92103
"@
93104
}
94105
New-IseSnippet @snippet
106+
}
95107

108+
if(!$snips.Where{$_.Name -like 'Run SQL query with SMO*'})
109+
{
96110
$snippet = @{
97111
Title = 'Run SQL query with SMO'
98112
Description = 'creates SMO object and runs a sql command'
@@ -107,7 +121,10 @@ $snippet = @{
107121
"@
108122
}
109123
New-IseSnippet @snippet
124+
}
110125

126+
if(!$snips.Where{$_.Name -like 'SQL Assemblies*'})
127+
{
111128
$snippet = @{
112129
Title = 'SQL Assemblies'
113130
Description = 'SQL Assemblies'
@@ -119,4 +136,5 @@ $snippet = @{
119136
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo")
120137
"@
121138
}
122-
New-IseSnippet @snippet
139+
New-IseSnippet @snippet
140+
}

Update-AllModules.ps1

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
## from @jeffhicks https://gist.github.com/jdhitsolutions/8a49a59c5dd19da9dde6051b3e58d2d0#file-check-moduleupdate-ps1
2+
3+
##
4+
function Update-AllModules
5+
{
6+
[cmdletbinding()]
7+
Param()
8+
function Check-AllModules
9+
{
10+
[cmdletbinding()]
11+
Param()
12+
Write-Verbose "Getting installed modules"
13+
$modules = Get-Module -ListAvailable
14+
15+
#group to identify modules with multiple versions installed
16+
$g = $modules | group name -NoElement | where count -gt 1
17+
18+
Write-Verbose "Filter to modules from the PSGallery"
19+
$gallery = $modules.where({$_.repositorysourcelocation})
20+
21+
Write-Verbose "Comparing to online versions"
22+
foreach ($module in $gallery) {
23+
24+
#find the current version in the gallery
25+
Try {
26+
$online = Find-Module -Name $module.name -Repository PSGallery -ErrorAction Stop
27+
}
28+
Catch {
29+
Write-Warning "Module $($module.name) was not found in the PSGallery"
30+
}
31+
32+
#compare versions
33+
if ($online.version -gt $module.version) {
34+
$UpdateAvailable = $True
35+
}
36+
else {
37+
$UpdateAvailable = $False
38+
}
39+
40+
#write a custom object to the pipeline
41+
[pscustomobject]@{
42+
Name = $module.name
43+
MultipleVersions = ($g.name -contains $module.name)
44+
InstalledVersion = $module.version
45+
OnlineVersion = $online.version
46+
Update = $UpdateAvailable
47+
Path = $module.modulebase
48+
}
49+
50+
} #foreach
51+
52+
53+
Write-Verbose "Check complete"
54+
55+
}
56+
Check-AllModules| Out-Gridview -title "Select modules to update" -PassThru | foreach {
57+
    Write-Host "Updating $($_.name)"
58+
    ## update-module $_.name -force
59+
}
60+
}

0 commit comments

Comments
 (0)