full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/Github/luisDavid4_devexpressLogin/WcfServiceA/packages/EntityFramework.5.0.0/tools/init.ps1
init.ps1
param($installPath, $toolsPath, $package, $project) $importedModule = Get-Module | ?{ $_.Name -eq 'EntityFramework' } if ($PSVersionTable.PSVersion -ge (New-Object Version @( 3, 0 ))) { $thisModuleManifest = 'EntityFramework.PS3.psd1' } else { $thisModuleManifest = 'EntityFramework.psd1' } $thisModule...
PowerShellCorpus/Github/luisDavid4_devexpressLogin/WcfServiceA/packages/EntityFramework.5.0.0/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) function Invoke-ConnectionFactoryConfigurator($assemblyPath, $project) { $appDomain = [AppDomain]::CreateDomain( 'EntityFramework.PowerShell', $null, (New-Object System.AppDomainSetup -Property @{ ShadowCopyFiles = 'true' })) ...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/jQuery.1.10.2/Tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # Determine the file paths $projectIntelliSenseFilePath = Join-Path $projectScriptsFolderPath $intelliSenseFileName $origIntelliSenseFilePath = Join-Path $toolsPath $intelliSenseFileName if (Test-Path $projectIntelliSense...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/jQuery.1.10.2/Tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # VS 11 and above supports the new intellisense JS files $vsVersion = [System.Version]::Parse($dte.Version) $supportsJsIntelliSenseFile = $vsVersion.Major -ge 11 if (-not $supportsJsIntelliSenseFile) { $displayVersio...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/jQuery.1.10.2/Tools/common.ps1
common.ps1
function Get-Checksum($file) { $cryptoProvider = New-Object "System.Security.Cryptography.MD5CryptoServiceProvider" $fileInfo = Get-Item $file trap { ; continue } $stream = $fileInfo.OpenRead() if ($? -eq $false) { # Couldn't open file for reading return $null } $bytes = $...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/Modernizr.2.6.2/Tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # Update the _references.js file Remove-Reference $scriptsFolderProjectItem $modernizrFileNameRegEx
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/Modernizr.2.6.2/Tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) if ($scriptsFolderProjectItem -eq $null) { # No Scripts folder Write-Host "No Scripts folder found" exit } # Update the _references.js file AddOrUpdate-Reference $scriptsFolderProjectItem $modernizrFileName...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/Modernizr.2.6.2/Tools/common.ps1
common.ps1
function AddOrUpdate-Reference($scriptsFolderProjectItem, $fileNamePattern, $newFileName) { try { $referencesFileProjectItem = $scriptsFolderProjectItem.ProjectItems.Item("_references.js") } catch { # _references.js file not found return } if ($referencesFileProject...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/Microsoft.ApplicationInsights.WindowsServer.2.2.0/Tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) if ([System.IO.File]::Exists($project.FullName)) { function MarkItemASCopyToOutput($item) { Try { #mark it to copy if newer $item.Properties.Item("CopyToOutputDirectory").Value = 2 } Catch { write-host $_.Exception.ToString() }...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/EntityFramework.6.1.3/tools/init.ps1
init.ps1
param($installPath, $toolsPath, $package, $project) if (Get-Module | ?{ $_.Name -eq 'EntityFramework' }) { Remove-Module EntityFramework } Import-Module (Join-Path $toolsPath EntityFramework.psd1) # SIG # Begin signature block # MIIa4AYJKoZIhvcNAQcCoIIa0TCCGs0CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQ...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/EntityFramework.6.1.3/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) Initialize-EFConfiguration $project Add-EFProvider $project 'System.Data.SqlClient' 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' Write-Host Write-Host "Type 'get-help EntityFramework' to see all available Entity Framework comma...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0/tools/init.ps1
init.ps1
param($installPath, $toolsPath, $package, $project) $compilerPackageName = 'Microsoft.Net.Compilers' $roslynSubFolder = 'roslyn' if ($project -eq $null) { $project = Get-Project } $libDirectory = Join-Path $installPath 'lib\net45' $packageDirectory = Split-Path $installPath $compilerPackage = Get-Chil...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0/tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) $roslynSubFolder = 'roslyn' if ($project -eq $null) { $project = Get-Project } $projectRoot = $project.Properties.Item('FullPath').Value $binDirectory = Join-Path $projectRoot 'bin' $targetDirectory = Join-Path $binDirectory $roslynSubFolder if (Te...
PowerShellCorpus/Github/StormOrder_Duo-Project/csharpding/packages/Newtonsoft.Json.6.0.4/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) # open json.net splash page on package install # don't open if json.net is installed as a dependency try { $url = "http://james.newtonking.com/json" $dte2 = Get-Interface $dte ([EnvDTE80.DTE2]) if ($dte2.ActiveWindow.Caption -eq "Package Manager Con...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/jQuery.1.10.2/Tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # Determine the file paths $projectIntelliSenseFilePath = Join-Path $projectScriptsFolderPath $intelliSenseFileName $origIntelliSenseFilePath = Join-Path $toolsPath $intelliSenseFileName if (Test-Path $projectIntelliSense...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/jQuery.1.10.2/Tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # VS 11 and above supports the new intellisense JS files $vsVersion = [System.Version]::Parse($dte.Version) $supportsJsIntelliSenseFile = $vsVersion.Major -ge 11 if (-not $supportsJsIntelliSenseFile) { $displayVersio...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/jQuery.1.10.2/Tools/common.ps1
common.ps1
function Get-Checksum($file) { $cryptoProvider = New-Object "System.Security.Cryptography.MD5CryptoServiceProvider" $fileInfo = Get-Item $file trap { ; continue } $stream = $fileInfo.OpenRead() if ($? -eq $false) { # Couldn't open file for reading return $null } $bytes = $...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/Modernizr.2.6.2/Tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # Update the _references.js file Remove-Reference $scriptsFolderProjectItem $modernizrFileNameRegEx
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/Modernizr.2.6.2/Tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) if ($scriptsFolderProjectItem -eq $null) { # No Scripts folder Write-Host "No Scripts folder found" exit } # Update the _references.js file AddOrUpdate-Reference $scriptsFolderProjectItem $modernizrFileName...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/Modernizr.2.6.2/Tools/common.ps1
common.ps1
function AddOrUpdate-Reference($scriptsFolderProjectItem, $fileNamePattern, $newFileName) { try { $referencesFileProjectItem = $scriptsFolderProjectItem.ProjectItems.Item("_references.js") } catch { # _references.js file not found return } if ($referencesFileProject...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/WebGrease.1.5.2/tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) # Visual Studio execution done via NuGet Package Manager Function VSExecution($toolsPath, $project) { $project.DTE.ExecuteCommand("File.SaveAll", [system.string]::Empty) # Get the msbuild version of the project and add the import $msbuild = [Microsof...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/WebGrease.1.5.2/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) # Return a relative path with reference to root as Uri object # $rootPath - root path # $relativePath - relative path # $appendToRelativePath - Optional parameter. If provided will be appended to relative Path using Path.Combine() Function GetRelativeUri($root...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/EntityFramework.6.1.3/tools/init.ps1
init.ps1
param($installPath, $toolsPath, $package, $project) if (Get-Module | ?{ $_.Name -eq 'EntityFramework' }) { Remove-Module EntityFramework } Import-Module (Join-Path $toolsPath EntityFramework.psd1) # SIG # Begin signature block # MIIa4AYJKoZIhvcNAQcCoIIa0TCCGs0CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQ...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/EntityFramework.6.1.3/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) Initialize-EFConfiguration $project Add-EFProvider $project 'System.Data.SqlClient' 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' Write-Host Write-Host "Type 'get-help EntityFramework' to see all available Entity Framework comma...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/EntityFramework.6.1.0/tools/init.ps1
init.ps1
param($installPath, $toolsPath, $package, $project) if (Get-Module | ?{ $_.Name -eq 'EntityFramework' }) { Remove-Module EntityFramework } Import-Module (Join-Path $toolsPath EntityFramework.psd1) # SIG # Begin signature block # MIIarwYJKoZIhvcNAQcCoIIaoDCCGpwCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQ...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/EntityFramework.6.1.0/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) Initialize-EFConfiguration $project Add-EFProvider $project 'System.Data.SqlClient' 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' Write-Host Write-Host "Type 'get-help EntityFramework' to see all available Entity Framework comma...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0/tools/init.ps1
init.ps1
param($installPath, $toolsPath, $package, $project) $compilerPackageName = 'Microsoft.Net.Compilers' $roslynSubFolder = 'roslyn' if ($project -eq $null) { $project = Get-Project } $libDirectory = Join-Path $installPath 'lib\net45' $packageDirectory = Split-Path $installPath $compilerPackage = Get-Chil...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0/tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) $roslynSubFolder = 'roslyn' if ($project -eq $null) { $project = Get-Project } $projectRoot = $project.Properties.Item('FullPath').Value $binDirectory = Join-Path $projectRoot 'bin' $targetDirectory = Join-Path $binDirectory $roslynSubFolder if (Te...
PowerShellCorpus/Github/georgimanov_AngularJS/Exam - Anguler - SPA Exam 2015 - Source Control System/SourceControlSystem-Server/packages/Newtonsoft.Json.6.0.4/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) # open json.net splash page on package install # don't open if json.net is installed as a dependency try { $url = "http://james.newtonking.com/json" $dte2 = Get-Interface $dte ([EnvDTE80.DTE2]) if ($dte2.ActiveWindow.Caption -eq "Package Manager Con...
PowerShellCorpus/Github/georgimanov_AngularJS/TicTacToe/ASP.NET-Web-API-Tic-Tac-Toe-Live/packages/jQuery.1.10.2/Tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # Determine the file paths $projectIntelliSenseFilePath = Join-Path $projectScriptsFolderPath $intelliSenseFileName $origIntelliSenseFilePath = Join-Path $toolsPath $intelliSenseFileName if (Test-Path $projectIntelliSense...
PowerShellCorpus/Github/georgimanov_AngularJS/TicTacToe/ASP.NET-Web-API-Tic-Tac-Toe-Live/packages/jQuery.1.10.2/Tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # VS 11 and above supports the new intellisense JS files $vsVersion = [System.Version]::Parse($dte.Version) $supportsJsIntelliSenseFile = $vsVersion.Major -ge 11 if (-not $supportsJsIntelliSenseFile) { $displayVersio...
PowerShellCorpus/Github/georgimanov_AngularJS/TicTacToe/ASP.NET-Web-API-Tic-Tac-Toe-Live/packages/jQuery.1.10.2/Tools/common.ps1
common.ps1
function Get-Checksum($file) { $cryptoProvider = New-Object "System.Security.Cryptography.MD5CryptoServiceProvider" $fileInfo = Get-Item $file trap { ; continue } $stream = $fileInfo.OpenRead() if ($? -eq $false) { # Couldn't open file for reading return $null } $bytes = $...
PowerShellCorpus/Github/georgimanov_AngularJS/TicTacToe/ASP.NET-Web-API-Tic-Tac-Toe-Live/packages/Modernizr.2.6.2/Tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # Update the _references.js file Remove-Reference $scriptsFolderProjectItem $modernizrFileNameRegEx
PowerShellCorpus/Github/georgimanov_AngularJS/TicTacToe/ASP.NET-Web-API-Tic-Tac-Toe-Live/packages/Modernizr.2.6.2/Tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) if ($scriptsFolderProjectItem -eq $null) { # No Scripts folder Write-Host "No Scripts folder found" exit } # Update the _references.js file AddOrUpdate-Reference $scriptsFolderProjectItem $modernizrFileName...
PowerShellCorpus/Github/georgimanov_AngularJS/TicTacToe/ASP.NET-Web-API-Tic-Tac-Toe-Live/packages/Modernizr.2.6.2/Tools/common.ps1
common.ps1
function AddOrUpdate-Reference($scriptsFolderProjectItem, $fileNamePattern, $newFileName) { try { $referencesFileProjectItem = $scriptsFolderProjectItem.ProjectItems.Item("_references.js") } catch { # _references.js file not found return } if ($referencesFileProject...
PowerShellCorpus/Github/georgimanov_AngularJS/TicTacToe/ASP.NET-Web-API-Tic-Tac-Toe-Live/packages/WebGrease.1.5.2/tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) # Visual Studio execution done via NuGet Package Manager Function VSExecution($toolsPath, $project) { $project.DTE.ExecuteCommand("File.SaveAll", [system.string]::Empty) # Get the msbuild version of the project and add the import $msbuild = [Microsof...
PowerShellCorpus/Github/georgimanov_AngularJS/TicTacToe/ASP.NET-Web-API-Tic-Tac-Toe-Live/packages/WebGrease.1.5.2/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) # Return a relative path with reference to root as Uri object # $rootPath - root path # $relativePath - relative path # $appendToRelativePath - Optional parameter. If provided will be appended to relative Path using Path.Combine() Function GetRelativeUri($root...
PowerShellCorpus/Github/georgimanov_AngularJS/TicTacToe/ASP.NET-Web-API-Tic-Tac-Toe-Live/packages/EntityFramework.6.1.0/tools/init.ps1
init.ps1
param($installPath, $toolsPath, $package, $project) if (Get-Module | ?{ $_.Name -eq 'EntityFramework' }) { Remove-Module EntityFramework } Import-Module (Join-Path $toolsPath EntityFramework.psd1) # SIG # Begin signature block # MIIarwYJKoZIhvcNAQcCoIIaoDCCGpwCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQ...
PowerShellCorpus/Github/georgimanov_AngularJS/TicTacToe/ASP.NET-Web-API-Tic-Tac-Toe-Live/packages/EntityFramework.6.1.0/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) Initialize-EFConfiguration $project Add-EFProvider $project 'System.Data.SqlClient' 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' Write-Host Write-Host "Type 'get-help EntityFramework' to see all available Entity Framework comma...
PowerShellCorpus/Github/etooby_ChocolateyConfig/run.example.ps1
run.example.ps1
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Write-Host "Running elevated..." $arguments = "& '" + $myinvocation.mycommand.definition + "'" Start-Process powershell -Verb runAs -Arg...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/AdvancedFunctionShell.ps1
AdvancedFunctionShell.ps1
function New-AdvancedFunction { <# .SYNOPSIS .EXAMPLE PS> New-AdvancedFunction -Param1 MYPARAM This example does something to this and that. .PARAMETER Param1 This param does this thing. .PARAMETER .PARAMETER .PARAMETER #> [CmdletBinding()] param ( [string]$Par...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/Get-TextLogEventWithin.ps1
Get-TextLogEventWithin.ps1
param([string]$ComputerName = 'localhost',[datetime]$StartTimestamp,[datetime]$EndTimestamp,[string]$LogFileExtension = 'log') ## Define the drives to look for log files if local or the shares to look for when remote if ($ComputerName -eq 'localhost') { $Locations = (Get-CimInstance -ClassName Win32_LogicalDis...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/Set-MyAdComputer.ps1
Set-MyAdComputer.ps1
param ([string]$Computername, [hashtable]$Attributes) ## Attempt to find the Computername try { $Computer = Get-AdComputer -Identity $Computername if (!$Computer) { ## If the Computername isn't found throw an error and exit Write-Error "The Computername '$Computername' does not exist" re...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/Remove-MyAcl.ps1
Remove-MyAcl.ps1
<# .SYNOPSIS This function allows an easy method to remove file system ACEs .PARAMETER Path The file path of a file .PARAMETER Identity The security principal to match with the ACE you'd like to remove. #> [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateScript({ Test-Path -Path $_ })] [stri...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/Get-InterestingEventsWithinTimeframe.ps1
Get-InterestingEventsWithinTimeframe.ps1
<# .SYNOPSIS This script finds all Windows events in all event logs and all log files on a local or remote machine recorded within a specific timeframe .EXAMPLE PS> Get-InterestingEventsWithinTimeframe.ps1 -Computername MYCOMPUTER -StartTimestamp '04-15-15 04:00' -EndTimestamp '04-15-15 08:00' -LogFileE...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/Get-MyAcl.ps1
Get-MyAcl.ps1
<# .SYNOPSIS This allows an easy method to get a file system access ACE .PARAMETER Path The file path of a file #> [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateScript({ Test-Path -Path $_ })] [string]$Path ) process { try { (Get-Acl -Path $Path).Access } catch { Write-Error "$...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/ToolSetExample.ps1
ToolSetExample.ps1
[CmdletBinding()] param( $RootHomeFolder = '\\labdc.lab.local\c$\usershomefolder', $Age, $ArchiveFolderPath = 'C:\ArchivedStuff', $FullPermissionGroup = 'administrators' ) . C:\FileFolderAutomator.ps1 ## Find the total file count of all files in the archived location before the move Write-Ver...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/Get-WinEventWithin.ps1
Get-WinEventWithin.ps1
param([string]$ComputerName = 'localhost',[datetime]$StartTimestamp,[datetime]$EndTimestamp) $Logs = (Get-WinEvent -ListLog * -ComputerName $ComputerName | where { $_.RecordCount }).LogName $FilterTable = @{ 'StartTime' = $StartTimestamp 'EndTime' = $EndTimestamp 'LogName' = $Logs } Get-WinEvent -Comput...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/Set-MyAdUser.ps1
Set-MyAdUser.ps1
param ([string]$Username, [hashtable]$Attributes) try { ## Attempt to find the username $UserAccount = Get-AdUser -Identity $Username if (!$UserAccount) { ## If the username isn't found throw an error and exit Write-Error "The username '$Username' does not exist" return } } cat...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/_DemoWalkthrough.ps1
_DemoWalkthrough.ps1
#region Demo setup $demoFolderPath = 'C:\Dropbox\GitRepos\Session-Content\Live Talks\TechMentor 2016\Building Real PowerShell Tools for Real Ops Tasks\Demos' #endregion #region AD Account Automator Tool #region Installing RSAT ## Install RSAT Invoke-Item "$demoFolderPath\Windows8.1-KB2693643-x64.msu" ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/Archive-File.ps1
Archive-File.ps1
<# .SYNOPSIS This attempts to recursively search for files in a directory that haven't been accessed in a specified time. Once found, this will move them to an archive location maintaining the same folder structure. .PARAMETER FolderPath The folder path to search for files .PARAMETER Age The age of the la...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/AdAccountManagementAutomator.ps1
AdAccountManagementAutomator.ps1
function New-EmployeeOnboardUser { <# .SYNOPSIS This function is part of the Active Directory Account Management Automator tool. It is used to perform all routine tasks that must be done when onboarding a new employee user account. .EXAMPLE PS> New-EmployeeOnboardUser -FirstName 'adam' -MiddleInitial D ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/New-EmployeeOnboardComputer.ps1
New-EmployeeOnboardComputer.ps1
param($Computername, $Location = 'OU=Corporate Computers') try { if (Get-AdComputer $Computername) { Write-Error "The computer name '$Computername' already exists" return } } catch { } $DomainDn = (Get-AdDomain).DistinguishedName $DefaultOuPath = "$Location,$DomainDn" New-ADComputer ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/CsvImportExample.ps1
CsvImportExample.ps1
#region Demo setup $demoFolderPath = 'C:\Dropbox\GitRepos\Session-Content\Live Talks\TechMentor 2016\Building Real PowerShell Tools for Real Ops Tasks\Demos\2. Wasting Time with ADUC' #endregion ## Dot source the functions . "$demoFolderPath\AdAccountManagementAutomator.ps1" $Employees = Import-Csv -Path C...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/New-EmployeeOnboardUser.ps1
New-EmployeeOnboardUser.ps1
param($FirstName,$MiddleInitial,$LastName,$Location = 'OU=Corporate Users',$Title) ## Not the best use of storing the password clear text ## Google on using stored secure strings on the file system as a way to get around this $DefaultPassword = 'p@$$w0rd12' $DomainDn = (Get-AdDomain).DistinguishedName $DefaultGr...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/LogInvestigator.ps1
LogInvestigator.ps1
function Get-WinEventWithin { <# .SYNOPSIS This function finds all events in all event logs on a local or remote computer between a start and end time .EXAMPLE PS> Get-WinEventWithin -StartTimestamp '04-15-15 04:00' -EndTimestamp '04-15-15 08:00' This example finds all events in all event log...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/Set-MyAcl.ps1
Set-MyAcl.ps1
<# .SYNOPSIS This allows an easy method to set a file system access ACE .PARAMETER Path The file path of a file .PARAMETER Identity The security principal you'd like to set the ACE to. This should be specified like DOMAIN\user or LOCALMACHINE\User. .PARAMETER Right One of many file system rights. For a...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/FileFolderAutomator.ps1
FileFolderAutomator.ps1
function Archive-File { <# .SYNOPSIS This attempts to recursively search for files in a directory that haven't been accessed in a specified time. Once found, this will move them to an archive location maintaining the same folder structure. .PARAMETER FolderPath The folder path to se...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/Building Real PowerShell Tools for Real Ops Tasks/Demos/Get-MyFile.ps1
Get-MyFile.ps1
param ([string[]]$Computername = 'localhost', [string]$Criteria, [hashtable]$Attributes) foreach ($Computer in $Computername) { ## Enumerate all of the default admin shares $CimInstParams = @{'ClassName' = 'Win32_Share'} if ($Computer -ne 'localhost') { $CimInstParams.Computername = $Computer ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/DemoWalkthrough.ps1
DemoWalkthrough.ps1
#region Demo prep $DemoFolderPath = 'C:\Dropbox\GitRepos\Session-Content\Live Talks\TechMentor 2016\No User Necessary - Creating an Automated Client Troubleshooting Tool\Demos' $ComputerName = 'CLIENT1' $ServerName = 'MEMBERSRV1' if (Test-Connection -ComputerName $ComputerName -Quiet -Count 1) { throw "Clien...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/GUI/Globals.ps1
Globals.ps1
#-------------------------------------------- # Declare Global Variables and Functions here #-------------------------------------------- #Sample function that provides the location of the script function Get-ScriptDirectory { <# .SYNOPSIS Get-ScriptDirectory returns the proper location of the script. ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/CLITools/WindowsServices.ps1
WindowsServices.ps1
## Save our test client into a variable in case we need to test against something else later $ComputerName = 'CLIENT1' #region REQUIREMENT 1 - Allow helpdesk to see all Windows services Get-Service -ComputerName $ComputerName | select * ## Get ALL properties just for investigation $services = Get-WmiObject -...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/CLITools/View-VNC.ps1
View-VNC.ps1
## Statically use CLIENT1 just for testing. We'll fill that in with a variable later. start -FilePath "\\MEMBERSRV1\ToolShare\vncviewer.exe" -Args "-connect CLIENT1"
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/CLITools/EventLogs.ps1
EventLogs.ps1
## Save our test client into a variable in case we need to test against something else later $ComputerName = 'CLIENT2' #region REQUIREMENT 1 - Allow helpdesk to query any event log by name ## Look through available cmdlets to figure out how to query event logs Get-Command -Name *eventlog* ## I see event log ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/CLITools/InstalledUpdates.ps1
InstalledUpdates.ps1
## Find installed updates on a test remote client Get-HotFix -ComputerName CLIENT1 ## Narrow this down to only the fields I'd like to see as defined by the helpdesk Get-HotFix -ComputerName CLIENT1 | select description, hotfixid
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/CLITools/Test-VNCInstalled.ps1
Test-VNCInstalled.ps1
function Test-VncInstalled { [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [ValidateScript({ Test-Connection -ComputerName $_ -Quiet -Count 1 })] [string]$ComputerName ) begin { $ErrorActionPreference = 'Stop' function Get-InstalledSoftware { <# .S...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/CLITools/Deploy-VNC.ps1
Deploy-VNC.ps1
function Deploy-Vnc { [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [ValidateScript({ Test-Connection -ComputerName $_ -Quiet -Count 1 })] [string]$ComputerName, [Parameter()] [ValidateNotNullOrEmpty()] [ValidateScript({ Test-Path -Path $_ -PathType Container...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/CLITools/VNC/View-VNC.ps1
View-VNC.ps1
## Statically use CLIENT2 just for testing. We'll fill that in with a variable later. & "\\MEMBERSRV1\ToolShare\VNC_Binaries\vncviewer.exe" -connect CLIENT2
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/CLITools/VNC/Test-VNCInstalled.ps1
Test-VNCInstalled.ps1
function Test-VncInstalled { [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [ValidateScript({ Test-Connection -ComputerName $_ -Quiet -Count 1 })] [string]$ComputerName ) begin { $ErrorActionPreference = 'Stop' function Get-InstalledSoftware { <# .S...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2016/No User Necessary - Creating an Automated Client Troubleshooting Tool/Demos/CLITools/VNC/Deploy-VNC.ps1
Deploy-VNC.ps1
function Deploy-Vnc { [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [ValidateScript({ Test-Connection -ComputerName $_ -Quiet -Count 1 })] [string]$ComputerName, [Parameter()] [ValidateNotNullOrEmpty()] [ValidateScript({ Test-Path -Path $_ -PathType Container...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Infrastructure Testing with Pester/Demos/_LeadDemo.ps1
_LeadDemo.ps1
$demoPath = 'C:\Dropbox\GitRepos\Session-Content\Live Talks\Youtube Live\Infrastructure Testing with Pester\Demos' ## DEMO 1 - Infrastructure Testing 101 psedit "$demoPath\Introduction\Infrastructure Testing 101.ps1" ## DEMO 2 - Reviewing the DSC configuration and making it happen psedit "$demoPath\Project\Conf...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Infrastructure Testing with Pester/Demos/Introduction/Creating Pester Tests.ps1
Creating Pester Tests.ps1
## This will be run LAST. This is after we first ensure all the dependencies are satisfied for the test ## and we've gathered up all actual and expected configuration items. ## This is the easy part. describe 'New-TestEnvironment' { it "creates the expected forest" { $forest.Name | should be $expectedAttrib...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Infrastructure Testing with Pester/Demos/Introduction/Defining Expected Behavior.ps1
Defining Expected Behavior.ps1
$demoPath = 'C:\Dropbox\GitRepos\Session-Content\Live Talks\Youtube Live\Infrastructure Testing with Pester\Demos' ## Read the expected attributes from ConfigurationData $expectedAttributes = Import-PowerShellDataFile -Path "$demoPath\Project\ConfigurationData.psd1" ## Reuse DSC's configuration data here. This ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Infrastructure Testing with Pester/Demos/Introduction/Cleanup.ps1
Cleanup.ps1
<# This can be implemented in the AfterAll block in the Pester describe block. This is the chance to perform any kind of cleanup necessary. In our demo today we're going to cleanup any dependencies created but you could also revert any changes made to an environment by the actual code you might be testing as well....
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Infrastructure Testing with Pester/Demos/Introduction/Infrastructure Testing 101.ps1
Infrastructure Testing 101.ps1
## Some outside process creates an AD user for some purpose $UserName = 'jjones' $NewUserParams = @{ 'UserPrincipalName' = $Username 'Name' = $Username 'GivenName' = 'Joe' 'Surname' = 'Jones' 'Title' = 'Manage of Accounting' 'SamAccountName' = $Username 'AccountPassword' = (ConvertTo-SecureString '...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Infrastructure Testing with Pester/Demos/Introduction/Dealing with Dependencies.ps1
Dealing with Dependencies.ps1
#region Dependency checking and remediation $hyperVCred = (Import-Clixml -Path "$PSScriptRoot\HyperVCredential.xml") $hyperVSrv = 'HYPERVSRV' <# ## We'll implement 3 actions - Check to see if the dependency is there - If not: - Either stop the tests from being performed in the first place - Implement co...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Infrastructure Testing with Pester/Demos/Project/New-TestEnvironment.Tests.ps1
New-TestEnvironment.Tests.ps1
<# .SYNOPSIS This is a set of Pester tests for for New-TestEnvironment script. .PARAMETER Full An optional switch parameter that is used if a full, from-scratch set of tests is to be executed. This accounts for dependencies, executes the code to be tested and tears down any chan...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Infrastructure Testing with Pester/Demos/Project/New-TestEnvironment.ps1
New-TestEnvironment.ps1
configuration NewTestEnvironment { Import-DscResource -ModuleName xActiveDirectory Node @($AllNodes).where({ $_.Purpose -eq 'Domain Controller' }).Nodename { LocalConfigurationManager { ActionA...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Presentation.Tests.ps1
Presentation.Tests.ps1
describe 'Presentation' { #$slideDeckPath = 'C:\DropBox\GitRepos\Session-Content\Live Talks\PowerShell Summit 2017\Unit Testing A-Z\slides.pptx' $slideDeckPath = "C:\Dropbox\GitRepos\Session-Content\Live Talks\DSC Camp 2016\slides.pptx" Add-type -AssemblyName office $script:application = New-Objec...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/PrepTests.ps1
PrepTests.ps1
$artifactsFolder = "C:\Dropbox\GitRepos\Session-Content\Live Talks\PowerShell Summit 2017\Unit Testing A-Z\Demos\Project\Artifacts" $employeesCsvPath = "$artifactsFolder\Employees.csv" describe 'CSV file' { it 'the CSV file exists in the expected location' { Test-Path -Path $employeesCsvPath | should be $tru...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/_LeadDemo.ps1
_LeadDemo.ps1
## Demo stuff return $demoPath = 'C:\Dropbox\GitRepos\Session-Content\Live Talks\PowerShell Summit 2017\Unit Testing A-Z\Demos' $talkPath = 'C:\Dropbox\GitRepos\Session-Content\Live Talks\PowerShell Summit 2017\Unit Testing A-Z' ###################### Invoke-Pester "$talkPath\Presentation.Tests.ps1" ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/PrepDemo.ps1
PrepDemo.ps1
$artifactsFolder = "C:\Dropbox\GitRepos\Session-Content\Live Talks\PowerShell Summit 2017\Unit Testing A-Z\Demos\Project\Artifacts" $employeesCsvPath = "$artifactsFolder\Employees.csv" $csvEmployees = Import-Csv -Path $employeesCsvPath foreach ($emp in $csvEmployees) { $firstInitial = $emp.FirstName.SubStri...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Introduction/Mocking.ps1
Mocking.ps1
######################### ## Mocking basics ######################### function Do-Thing { param($Action) Write-Host 'Doing the thing...' Write-Output "I did the thing $Action!" } describe 'Do-Thing' { it 'does the thing' { ## I know the ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Introduction/MyScriptv1.Tests.ps1
MyScriptv1.Tests.ps1
## Everything you need to create a test script describe 'MyScript Tests' { context 'optional context to separate out tests' { it 'should return 1 plus the Number passed to it' { & "$PSScriptRoot\MyScriptv1.ps1" -Number 1 | should be 2 } 2..10 | foreach { ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Introduction/MyScriptv2.Tests.ps1
MyScriptv2.Tests.ps1
## Test the functions . "$PSScriptRoot\Add-Number.ps1" describe 'Add-Number' { ## Create a static It block it 'should return 1 plus the Number passed to it' { Add-Number -Number 1 | should be 2 } ## Creating it blocks dynamically based on different inputs 2..10 | foreach { ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Introduction/ThePointIs.Tests.ps1
ThePointIs.Tests.ps1
. "$PSScriptRoot\ThePointIs.ps1" describe 'Remove-Software' { mock 'Start-Process' mock 'Remove-Item' context 'when -Force is used' { mock 'Get-InstalledSoftware' { [pscustomobject]@{ Guid = 'YOURGUIDHERE' } } it 'should r...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Introduction/MyScriptv2.ps1
MyScriptv2.ps1
param($Number) . "$PSScriptRoot\Add-Number.ps1" Add-Number -Number $Number
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Introduction/Add-Number.ps1
Add-Number.ps1
function Add-Number { param ($Number) $Number + 1 }
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Introduction/ThePointIs.ps1
ThePointIs.ps1
function Remove-Software { [OutputType([void])] [CmdletBinding()] param ( [Parameter(Mandatory)] [string]$Name, [Parameter()] [switch]$Force ) ## Enumerate all software to find the GUID $guid = Get-InstalledSoftware -Name $Name | Select-Object ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Introduction/MyScriptv1.ps1
MyScriptv1.ps1
param($Number) $Number + 1
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Project/Sync-AdUser.Tests.ps1
Sync-AdUser.Tests.ps1
## TESTS FOR THE SYNC-ADUSER.PS1 SCRIPT. ALL FUNCTIONS WITHIN THIS SCRIPT ALL Have ## TESTS FOR EACH OF THEM IN THE ADUSERSYNC MODULE TESTS. ############ # ARRANGE ############ ## Pre-populate the dummy CSV file contents we'll be testing with for both active and inactive employees ## It's up here because this...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Project/Sync-AdUser.ps1
Sync-AdUser.ps1
param( [Parameter()] [ValidateNotNullOrEmpty()] [string]$CsvFilePath ) if ($PSBoundParameters.ContainsKey('CsvFilePath')) { $activeEmployees = Get-ActiveEmployee @getEmpParams } else { $activeEmployees = Get-ActiveEmployee } if (-not $activeEmployees) { throw 'No employees found ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Project/Sync-AdUser-needswork.ps1
Sync-AdUser-needswork.ps1
[CmdletBinding()] param() <# This is a typical procedural PowerShell script. It is used to "sync" a number of employees stored in a CSV file to Active Directory. This mimics a typical script you might use in your daily work life. You've got a set of requirements like HR handing you a CSV and saying they need that ...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Project/TestFramework.ps1
TestFramework.ps1
describe 'Get-AdUserDefaultPassword' { it 'builds the default FilePath parameter correctly and passes it to Import-CliXml' { } it 'returns a single secure string' { } it 'converts the expected password to a secure string' { } } describe 'Get-ActiveEmployee' {...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/Youtube Live/Unit Testing A-Z/Demos/Project/Module/AdUserSync.Tests.ps1
AdUserSync.Tests.ps1
## TESTS FOR ALL FUNCTIONS REFERENCED IN THE SYNC-ADUSER.PS1 SCRIPT. ## Remove all loaded functions Get-Module -Name AdUserSync -All | Remove-Module -Force ## Ensure functions are not called from modules that are already loaded Import-Module "$PSScriptRoot\AdUserSync.psm1" -Force InModuleScope 'AdUserSync' {...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2015 - Automating Software Install with Powershell/Demos/Start-Demo.ps1
Start-Demo.ps1
$script:WorkingDir = $MyInvocation.MyCommand.Path | Split-Path -Parent $script:Clients = @('WINSRV2012R2-2.MYLAB.LOCAL', 'WIN7X64.MYLAB.LOCAL','WIN81-1.MYLAB.LOCAL') ## Reboot all clients Restart-Computer -ComputerName $Clients -Force Read-Host 'Rebooting clients.. wait a sec..' cls Read-Host 'Did you mak...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2015 - Automating Software Install with Powershell/Demos/Cleanup.ps1
Cleanup.ps1
[CmdletBinding()] param( [Parameter(Mandatory)] [string[]]$Client, [Parameter()] [string]$ClientDeploymentFolder = 'C:\MyDeployment' ) foreach ($pc in $Client) { try { if (-not (Test-Connection -ComputerName $pc -Quiet -Count 1)) { Write-Warning -Message "$pc`: OFFLIN...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2015 - Automating Software Install with Powershell/Demos/LaunchScript.ps1
LaunchScript.ps1
[CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [string[]]$Client, [Parameter(Mandatory)] [ValidateSet('Install','Upgrade','Uninstall','Detect')] [string]$Type, [Parameter(Mandatory)] [ValidateScript( { Test-Path -Path $_ -PathType Container })] [string]$ServerSideClientDeploymentF...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2015 - Automating Software Install with Powershell/Demos/2. Logging/1. Logging/logging.ps1
logging.ps1
## Bring up CMTrace. CMTrace is great for formatting, real-time log analysis, etc & "C:\Program Files (x86)\ConfigMgr 2012 Toolkit R2\ClientTools\CMTrace.exe" ## Show log levels Import-Module \\LABDC.LAB.LOCAL\Deployments\SoftwareInstallManager.psm1 Start-Log Write-Log -Message 'something normal' Write-Log -...
PowerShellCorpus/Github/adbertram_Session-Content/Live Talks/TechMentor 2015 - Automating Software Install with Powershell/Demos/4. Upgrades/1. Adobe Flash Player/uninstall.ps1
uninstall.ps1
Import-Module C:\MyDeployment\SoftwareInstallManager.psm1 -DisableNameChecking Start-Log $WorkingDir = $MyInvocation.MyCommand.Path | Split-Path -Parent if (Test-InstalledSoftware -Name 'Adobe Flash Player 10 Plugin' -Version '10.1.53.64') { Start-Process -FilePath "$WorkingDir\install_flash_player_10.1_non-i...