Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Search-Google
- <#
- .Synopsis
- Searches the Googes
- .DESCRIPTION
- Lets you quickly start a search from within Powershell
- .EXAMPLE
- Search-Google Error code 5
- --New google search results will open listing top entries for 'error code 5'
- .EXAMPLE
- search-google (gwmi win32_baseboard).Product maximum ram
- If you need to get the maximum ram for your motherboard, you can even use this
- type of syntax
- #>
- {
- Begin
- {
- $query='https://www.google.com/search?q='
- }
- Process
- {
- Write-Host $args.Count, "Arguments detected"
- "Parsing out Arguments: $args"
- for ($i=0;$i -le $args.Count;$i++){
- $args | % {"Arg $i `t $_ `t Length `t" + $_.Length, " characters";$i++} }
- $args | % {$query = $query + "$_+"}
- $url = "$query"
- }
- End
- {
- $url.Substring(0,$url.Length-1)
- "Final Search will be $url"
- "Invoking..."
- start "$url"
- }
- }
- Function Uptime{
- param([parameter(Mandatory=$false)][string]$computer=".")
- #$computer = read-host "Please type in computer name you would like to check uptime on"
- $lastboottime = (Get-WmiObject -Class Win32_OperatingSystem -computername $computer).LastBootUpTime
- $sysuptime = (Get-Date) – [System.Management.ManagementDateTimeconverter]::ToDateTime($lastboottime)
- Write-Host "$computer has been up for: " $sysuptime.days "days" $sysuptime.hours "hours" $sysuptime.minutes "minutes" $sysuptime.seconds "seconds"}
- Function diskusage
- {
- param([parameter(Mandatory=$false)][string]$remotepc=".")
- #$remotepc = Read-host 'For which computer?'
- Get-WmiObject win32_logicaldisk -ComputerName $remotepc -Filter "drivetype=3" | select SystemName,DeviceID,VolumeName,@{Name="Size(GB)";Expression={"0:N1}" -f($_.size/1gb)}},@{Name="FreeSpace(GB)";Expression={"{0:N1}" -f($_.freespace/1gb)}}}
- Function patches{
- param([parameter(Mandatory=$false)][string]$remotepc=".")
- #$remotepc = Read-host 'For which box?'
- Get-WmiObject -Class "win32_quickfixengineering" -ComputerName $remotepc | select hotfixid,installedon}
- function RemindMe-Comparators {
- $writeout = @"
- Windows PowerShell includes the following comparison operators:
- -eq
- -ne
- -gt
- -ge
- -lt
- -le
- -Like
- -NotLike
- -Match
- -NotMatch
- -Contains
- -NotContains
- -In
- -NotIn
- -Replace
- "@
- "$writeout"
- }
- function RemindMe-Git{
- $giturl = "https://github.com/feelingsofwhite/MaximumPower"
- $nav = Read-host "Navigate to Azure?"
- if ($nav -eq 'Y')
- {$ie.visible = $true}
- #"Chxda7izL3GR" | clip
- }
- $custom = @"
- --Custom Commands Available--
- RemindMe-Azure`t`tDisplay Reminder information for Azure
- RemindMe-Comparators`tDisplay Reminder information on Comparison Operators
- RemindMe-Git`t`tDisplay Remind information on how to use Git
- Search-Google`t`tQuickly Launch a google Search
- Play-Bubbles`t`tPop `dem Bubbles!
- Get-SwitchStatus`t`tSee the status of users
- Uptime`t`tEasy Uptime
- DiskUsage`t`tGets Disk Usage
- Patches`t`tLists Patches
- "@
- Write-Host -fore Yellow -Back Black $custom
- #Write-Host -fore Yellow -Back Black "Searching for Azure and Azure Platform Modules..."
- if (Test-path "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\"){
- Write-Host "Azure Modules found, importing"
- gci 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure' *.psd1 | select -ExpandProperty Fullname| Import-module -PassThru
- }
- ELSE
- {#Write-Warning "Azure and Azure Platform Modules not detected, skipping..."
- }
- if (Test-path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"){
- import-Module "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" -PassThru
- }
- ELSE
- {#Write-Warning "Config Manager PowerShell module not detected, skipping..."
- }
- if (test-path C:\Users\sowen\dropbox\docs\iVision\Recall\Scripts){"Recall Scripts Directory detected, must be iVision laptop, navigating...";Set-location "C:\Users\sowen\dropbox\docs\iVision\Recall\Scripts"}
- function Play-Bubble{
- [CmdletBinding()]
- Param(
- [Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
- $bubbles="0"
- )
- $sound = new-Object System.Media.SoundPlayer;
- $sound.SoundLocation = "C:\users\sowen\Downloads\bubble_Pop-Sound_Explorer-1206462561.wav"
- 1..[int]$bubbles | % {$sound.Play();start-sleep -Milliseconds 150}
- }
- ####################################################################
- # ----Name : iVision Recall Quest Switch Status
- # ---Author: Stephen Owen, iVision, 7.24.2014
- # Function : Use this tool to determine if a user account has switched or not, based on the account's Source targetAddress property
- # ---Usage : Get-SwitchedStatus <$username>
- Function Get-SwitchedStatus {
- <#
- .Synopsis
- Use this tool to determine if a user account has switched or not, based on the account's Source targetAddress property
- .DESCRIPTION
- This tool connects to the Source (legacy) AD Domain and looks up the specified user object, returning the .targetAddress property
- connects to the target domain to move the user account to the correct OU
- .PARAMETER UserName
- <Mandatory> Specify the username to inquire
- .EXAMPLE
- Get-SwitchedStatus -UserName Stephen.Owen
- > This tool will connect to the source, and grab the targetAddress property of the object <Stephen.Owen>. If this contains *@source.qmm, the account is most likely unSwitched. If this value contains *@target.qmm, then the account is most likely Switched.
- .EXAMPLE
- "Stephen.Owen","Mark.Wuerslin" | ForEach-Object {Get-SwitchedStatus -UserName $_}
- > Perform Get-SwitchedStatus on both Stephen.Owen, then Mark.Wuerslin
- #>
- [CmdletBinding()]
- param([parameter(Mandatory=$true)][string]$UserName,[string]$service="amatldc01")
- #Write-host "Checking for Quest Active Roles PSSnapIn..." -ForegroundColor White -NoNewline
- $Host.UI.RawUI.WindowTitle="---Get UserSwitchedStatus Tool"
- Write-Progress -Activity ("Checking for Quest Active Roles PSSnapIn...") -PercentComplete 25 -Status "Connecting"
- if (-not ((Get-PSSnapin).Name -contains "Quest.ActiveRoles.ADManagement")){
- try {Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction Stop}
- catch{
- #Write-host "[ERROR]" -ForegroundColor Red
- Write-Warning "This tool depends on the Quest Active Roles tools to operate"
- $DL = Read-Host "Download? Y/N"
- IF ($DL -eq "Y"){
- Start 'http://www.quest.com/quest_download_assets/individual_components/Quest_ActiveRolesManagementShellforActiveDirectoryx86_151.msi'
- "Exiting..."
- }
- ELSE{"Exiting...";break}
- BREAK
- }
- finally{#Write-Host "[OKAY]" -ForegroundColor Green
- }
- }
- ELSE{start-sleep -Milliseconds 150
- #Write-Host "[OKAY]" -ForegroundColor Green
- Write-Progress -Activity ("Checking for Quest Active Roles PSSnapIn...") -PercentComplete 50
- }
- if (-not($credential)){
- $credential= Get-Credential -Message "Enter credentials which can browse AD in Source and Target"}ELSE{"Cached credential detected, continuing..."
- }
- #Connect to source
- start-sleep -Milliseconds 150
- #Write-Host "Connecting to Source..." -NoNewline
- Write-Progress -Activity ("Connecting to source...") -PercentComplete 50 -Status "Connecting..."
- try {Connect-QADService $service -Credential $credential -ErrorAction Stop}
- Catch{
- Write-warning "Error ocurred connecting to AMATLDC01 to pull source OU paths, check credentials..."
- BREAK
- }
- finally{#Write-Host "[OKAY]" -ForegroundColor Green
- }
- Try {start-sleep -Milliseconds 150
- Write-Progress -Activity ("Looking up $username on " + (Connect-QADService).DefaultNamingContext.DnsName) -PercentComplete 75 -Status "Gathering Info..."
- $user = get-qaduser $username -DontUseDefaultIncludedProperties -IncludedProperties targetAddress -Service $service -ConnectionAccount $credential.UserName -ConnectionPassword $credential.Password -ErrorAction Stop
- Write-Debug "Troubleshoot `$user"}
- catch {Write-Warning ("Unable to perform Get-QADUser for object $username from service: " + (Connect-QADService).DefaultNamingContext.DnsName + "`n check UserName")
- }
- Write-Debug "Troubleshoot `$user"
- if ($user){
- if (-not($user.targetAddress)){
- Write-Warning ("Unable to find targetAddress: $userName has NOT Switched")
- BREAK
- }
- }
- if ($user.targetAddress -like "*@target.qmm"){"$userName Has Switched"}
- ELSE{"$user HAS NOT Switched"}
- }
Add Comment
Please, Sign In to add comment