diff --git a/Get-CommunityRepos.ps1 b/Get-CommunityRepos.ps1 deleted file mode 100644 index 5f28270..0000000 --- a/Get-CommunityRepos.ps1 +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PSModule/PSModule-SetWinEvtLog.psm1 b/PSModule/old/PSModule-SetWinEvtLog.psm1 similarity index 100% rename from PSModule/PSModule-SetWinEvtLog.psm1 rename to PSModule/old/PSModule-SetWinEvtLog.psm1 diff --git a/PSModule/PSModule.psm1 b/PSModule/old/PSModule.psm1 similarity index 100% rename from PSModule/PSModule.psm1 rename to PSModule/old/PSModule.psm1 diff --git a/PSModule/old/PSModule-Cleanup.psm1 b/PSModule/older/PSModule-Cleanup.psm1 similarity index 100% rename from PSModule/old/PSModule-Cleanup.psm1 rename to PSModule/older/PSModule-Cleanup.psm1 diff --git a/PSModule/old/PSModule-Create.psm1 b/PSModule/older/PSModule-Create.psm1 similarity index 100% rename from PSModule/old/PSModule-Create.psm1 rename to PSModule/older/PSModule-Create.psm1 diff --git a/PSModule/old/PSModule-Fix.psm1 b/PSModule/older/PSModule-Fix.psm1 similarity index 100% rename from PSModule/old/PSModule-Fix.psm1 rename to PSModule/older/PSModule-Fix.psm1 diff --git a/PSModule/old/PSModule-Get.psm1 b/PSModule/older/PSModule-Get.psm1 similarity index 100% rename from PSModule/old/PSModule-Get.psm1 rename to PSModule/older/PSModule-Get.psm1 diff --git a/PSModule/old/PSModule-Install.psm1 b/PSModule/older/PSModule-Install.psm1 similarity index 100% rename from PSModule/old/PSModule-Install.psm1 rename to PSModule/older/PSModule-Install.psm1 diff --git a/PSModule/old/PSModule-Remediation.psm1 b/PSModule/older/PSModule-Remediation.psm1 similarity index 100% rename from PSModule/old/PSModule-Remediation.psm1 rename to PSModule/older/PSModule-Remediation.psm1 diff --git a/PSModule/old/PSModule-Remove.psm1 b/PSModule/older/PSModule-Remove.psm1 similarity index 100% rename from PSModule/old/PSModule-Remove.psm1 rename to PSModule/older/PSModule-Remove.psm1 diff --git a/PSModule/old/PSModule-Start.psm1 b/PSModule/older/PSModule-Start.psm1 similarity index 100% rename from PSModule/old/PSModule-Start.psm1 rename to PSModule/older/PSModule-Start.psm1 diff --git a/PSModule/old/PSModule-Upload.psm1 b/PSModule/older/PSModule-Upload.psm1 similarity index 100% rename from PSModule/old/PSModule-Upload.psm1 rename to PSModule/older/PSModule-Upload.psm1 diff --git a/README.md b/README.md index 3ce6fdc..8c29c43 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # Management Scripts +Dot source any of the Powershell scripts with the following: + . $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('$URL'))) \ No newline at end of file diff --git a/Run-PSScript.ps1 b/Run-PSScript.ps1 index dd0be62..5fa0c65 100644 --- a/Run-PSScript.ps1 +++ b/Run-PSScript.ps1 @@ -1,32 +1,2 @@ #Requires -Version 2.0 -param( - [string]$Type='management-scripts', - [string]$Name, - [string]$Arguments) - -## Get rid of null arguments -If ( $Arguments -eq "null" ) { $Arguments = $null } - -## Make sure $Name and $Type are defined -If ( $Name -and $Type ) -{ - ## Form the URL to the specified script - $URL = "https://dev.emberkom.com/emberkom/${Type}/raw/branch/master/${Name}.ps1" - - ## Get the script - Write-Output "Retrieving : ${Name}.ps1" - Try { $Script = (New-Object Net.WebClient).DownloadString($URL) } - Catch { Write-Output $_.Exception.Message } - - ## Make a script block - Try { $ScriptBlock = [Scriptblock]::Create($Script) } - Catch { Write-Output $_.Exception.Message } - - ## Run the script any any arguments - Write-Output "Executing: ${Name}.ps1 ${Arguments}" - Try { Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments } - Catch { Write-Output $_.Exception.Message } -} - -Else { Write-Output "No script or type was specified" } \ No newline at end of file diff --git a/Tools.ps1 b/Tools.ps1 new file mode 100644 index 0000000..bd36cd8 --- /dev/null +++ b/Tools.ps1 @@ -0,0 +1,58 @@ +## Function to log activity to the configured log directory +Function global:Log +{ + +} + +## Function to determine if the current user context is an Administrator +Function global:IsAdmin +{ +If ( ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) ) +{ Return $true } Else { Return $false } +} + +## Runs a script from the repo +Function global:Run-PSScript +{ +param( + [string]$Type='management-scripts', + [string]$Name, + [string]$Arguments) + +## Get rid of null arguments +If ( $Arguments -eq "null" ) { $Arguments = $null } + +## Make sure $Name and $Type are defined +If ( $Name -and $Type ) +{ + ## Form the URL to the specified script + $URL = "https://dev.emberkom.com/emberkom/${Type}/raw/branch/master/${Name}.ps1" + + ## Get the script + Write-Output "Retrieving : ${Name}.ps1" + Try { $Script = (New-Object Net.WebClient).DownloadString($URL) } + Catch { Write-Output $_.Exception.Message } + + ## Make a script block + Try { $ScriptBlock = [Scriptblock]::Create($Script) } + Catch { Write-Output $_.Exception.Message } + + ## Run the script any any arguments + Write-Output "Executing: ${Name}.ps1 ${Arguments}" + Try { Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments } + Catch { Write-Output $_.Exception.Message } +} +Else { Write-Output "No script or type was specified" } +} + +## Function to return a version object from a string +Function Get-Version +{ +param([string]$Version) +[int]$Sets = 4 +$VersionArray = $Version.Split('.') +If ( $VersionArray.Count -le $Sets ) { $Sets = $VersionArray.Count } +For ($i = 0; $i -le ($Sets - 1); $i++) +{ $Return = '{0}.{1}' -f $Return, $VersionArray[$i] } +Return [version]$Return.Trim('.') +} \ No newline at end of file diff --git a/test.psm1 b/test.psm1 deleted file mode 100644 index 468ba27..0000000 --- a/test.psm1 +++ /dev/null @@ -1,4 +0,0 @@ -Function hw -{ - Write-Output "Hello world!" -} \ No newline at end of file