Skip to content

Instantly share code, notes, and snippets.

View pinecones-sx's full-sized avatar

Pinecones pinecones-sx

View GitHub Profile
@pinecones-sx
pinecones-sx / change-aduser-bat.ps1
Last active October 2, 2015 19:27
set AD users
(get-aduser -Filter * -Properties *) |
where {$_.ScriptPath -eq "BenefitsTrans.bat"} |
ForEach-Object {
Write-Host $_.Name
set-aduser $_.samaccountName -ScriptPath "BenefitsAdmin.bat"
Write-Host $_.Name $_.ScriptPath
}
@pinecones-sx
pinecones-sx / Get-ObjectTypeInfo.ps1
Created November 16, 2015 17:41
Pass an object into function, function starts a browser session with what MIGHT be the proper reference for the object type.
function Global:Get-ObjectTypeInfo{
param($objType)
$objTypeAsString=@()
if($objType -isnot [type]) {
If ($objType -is [string]) {$objTypeAsString=$objType}
Else{$objTypeAsString=($objType.GetType()).FullName}
}
Else{$objTypeAsString=$objType.FullName}
@pinecones-sx
pinecones-sx / fcobject.ps1
Created May 18, 2016 15:19
Issue w/function to create custom object
function global:Get-CompFolder{
param($iFolderLoc)
$objCompFolder = [Ordered]@{
'Location' = $iFolderLoc
'Folder' = Get-Item $iFolderLoc
'Tree' = Get-ChildItem $iFolderLoc -Recurse |
Add-Member -MemberType ScriptProperty -Name 'RelativeName' -Force -PassThru -Value {
$this.FullName -replace ('.*' + [regex]::escape($iFolderLoc))
}
@pinecones-sx
pinecones-sx / Export-Icon.ps1
Last active September 20, 2016 20:01
rips icons from executibles... has optional GUI filepicker
<# Export-Icon
Extracts the icon from an executible (.EXE) file.
By default, this will extract the icon to the same folder and name as
the BaseName of the executible, with a ".ICO" extension.
Usage:
-SourceEXE
Mandatory. This must be a valid UNC. (you can pass any file, but
it will most likely only work with .EXE files)
@pinecones-sx
pinecones-sx / Open-OneNoteNotebook.ps1
Created November 8, 2016 21:01
Open-OneNoteNotebook powershell function -- lets you open OneNote Notebooks
<# Open-OneNoteNotebook
Pass in the UNC path of a OneNote notebook folder, then this will add it to the
list of opened notebooks in OneNote.
Ex:
Open-OneNoteNotebook '\\consanto\public\KnowledgeBase\'
#>
If (-Not (Test-Path function:global:Open-OneNoteNotebook)) {
<# Enable-RemotePS
Uses PSEXEC to enable WSMan on a remote computer. Also enables remote PS execution, then returns
information on that comptuter--whether those features are enabled (WSMan control & remote PS),
also returns all compatible versions of .NET installed on that computer and the current PS version.
Usage:
Enable-RemotePS 'computerName.domain.com'
'computer1','computer2','computer3' | Enable-RemotePS
#>
<#
Verify contents between two tree structures and copy newer or missing files from the source to the destination
#>
 
function Global:Copy-Diff{
param($SourcePath,$DestinationPath,[switch]$Informational,[switch]$Force)
# Variable setup...
# Verify paths & normalize path names
@pinecones-sx
pinecones-sx / revamp-nestle.ps1
Last active March 1, 2017 16:57
fixed nested if
function Get-VersionAsInt {
param($VersionInfo,[switch]$FileVersion)
$digits = 6
If ($FileVersion){$iVersionNumber = $VersionInfo.FileVersion}
Else{$iVersionNumber = $VersionInfo.ProductVersion}
$rVersionInt = ''
@pinecones-sx
pinecones-sx / Uninstall-SysAid.ps1
Last active March 1, 2017 18:36
current SCCM-based uninstaller
<#
This checks for non-current copies of SysAid & uninstalls them.
FILES:
Uninstall-SysAid.ps1
This file. Must be run with execution policy bypassed:
powershell.exe -executionpolicy bypass -file .\Uninstall-SysAid.ps1
SysAidAgentx64.msi
This is the "install" file. We're using it with uninstall
switches to remove existing copies of SysAid.
@pinecones-sx
pinecones-sx / Uninstall-SysAidRegistry.ps1
Last active April 20, 2017 16:38
removes some registry points for SysAid
# Remove registry entries
$null = New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
# Remove registry entries
$oldRegKeys = `
'HKLM:\SOFTWARE\Ilient',
'HKLM:\SOFTWARE\Wow6432Node\Ilient',
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FC5E1D1D-6D3F-4844-A937-567D589F655E}'