Added try/catch

This commit is contained in:
dfinke
2018-07-04 18:58:40 -04:00
parent 35553baa05
commit b591a4ab18
17 changed files with 84 additions and 51 deletions

View File

@@ -1,8 +1,10 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$file = ".\conditionalTextFormatting.xlsx" $file = ".\conditionalTextFormatting.xlsx"
rm $file -ErrorAction Ignore Remove-Item $file -ErrorAction Ignore
Get-Service | Get-Service |
Select Status, Name, DisplayName, ServiceName | Select-Object Status, Name, DisplayName, ServiceName |
Export-Excel $file -Show -AutoSize -AutoFilter -ConditionalText $( Export-Excel $file -Show -AutoSize -AutoFilter -ConditionalText $(
New-ConditionalText stop New-ConditionalText stop
New-ConditionalText runn darkblue cyan New-ConditionalText runn darkblue cyan

View File

@@ -1,3 +1,5 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$ContainsBlanks = New-ConditionalText -ConditionalType ContainsBlanks $ContainsBlanks = New-ConditionalText -ConditionalType ContainsBlanks
$data = $( $data = $(
@@ -11,5 +13,5 @@ $data = $(
$file ="c:\temp\testblanks.xlsx" $file ="c:\temp\testblanks.xlsx"
rm $file -ErrorAction Ignore Remove-Item $file -ErrorAction Ignore
$data | Export-Excel $file -show -ConditionalText $ContainsBlanks $data | Export-Excel $file -show -ConditionalText $ContainsBlanks

View File

@@ -1,4 +1,6 @@
Remove-Item -Path .\test.xlsx -ErrorAction Ignore try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
Remove-Item -Path .\test.xlsx -ErrorAction Ignore
$excel = Get-Process | $excel = Get-Process |
Select-Object -Property Name,Company,Handles,CPU,PM,NPM,WS | Select-Object -Property Name,Company,Handles,CPU,PM,NPM,WS |

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
$data = $( $data = $(

View File

@@ -1,6 +1,8 @@
rm .\testExport.xlsx -ErrorAction Ignore try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
ps | where Company | select Company, Name, PM, Handles, *mem* | Remove-Item .\testExport.xlsx -ErrorAction Ignore
Get-Process | Where-Object Company | Select-Object Company, Name, PM, Handles, *mem* |
Export-Excel .\testExport.xlsx -Show -AutoSize -AutoNameRange ` Export-Excel .\testExport.xlsx -Show -AutoSize -AutoNameRange `
-ConditionalFormat $( -ConditionalFormat $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
$data = $( $data = $(

View File

@@ -1,6 +1,7 @@
ipmo ImportExcel -Force try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx" $f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore Remove-Item $f -ErrorAction Ignore
function Get-DateOffset ($days=0) { function Get-DateOffset ($days=0) {
(Get-Date).AddDays($days).ToShortDateString() (Get-Date).AddDays($days).ToShortDateString()