Skip to content

Instantly share code, notes, and snippets.

View shinjijai's full-sized avatar

shinjijai shinjijai

View GitHub Profile
@shinjijai
shinjijai / New-SecurePassFile.ps1
Last active October 10, 2017 16:25
Store encrypted password into a file
function New-SecurePass{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[System.Security.SecureString]$SecurePassword,
[Parameter(Mandatory=$false)]
[string]$FileName = "EncryptedPassword",
[Parameter(Mandatory=$false)]
[string]$KeyFilePath = ".\",
[Parameter(Mandatory=$false)]
@shinjijai
shinjijai / Disable-ExpiredAccounts.ps1
Last active January 17, 2018 20:08
Disable User accoiunts that are expired
#Requires -Version 4.0
#Requires -modules ActiveDirectory
function Send-AlertsMessage {
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)]
[String]$ToAddress,
[Parameter(Mandatory=$false)]
[String]$FromAddress = "_SERVICEACCOUNT@BLAH.COM",
[Parameter(Mandatory=$false)]
@shinjijai
shinjijai / Find-DuplicateFiles.ps1
Last active April 17, 2018 17:17
Takes an array of folder locations and exports a CSV file with the file hash, name and directory name.
$FolderLocation = @("FilePath1", "FilePath2", "FilePath3")
$AllFiles = @()
$FileList = @()
foreach($RootFolder in $FolderLocation) {
$AllFiles += Get-ChildItem -Path $RootFolder -File -Recurse
}
foreach($File in $AllFiles) {
$FileHash = Get-FileHash $File.PSPath | Select-Object Hash -ExpandProperty Hash
$FileInfo = [PSCustomObject]@{
Folder = $File.DirectoryName
@shinjijai
shinjijai / Connect-Exchange.ps1
Last active April 24, 2018 16:58
Function that'll connect to either on premise Exchange or Office 365 Exchange
#Requires -Version 4.0
#Requires -modules ActiveDirectory
function Connect-Exchange {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,
HelpMessage="User admin credentials")]
[System.Management.Automation.PSCredential]$Credential,
[Parameter(Mandatory=$false)]
$URI = "https://outlook.office365.com/powershell-liveid/",
@shinjijai
shinjijai / Get-BaseOU.ps1
Last active May 11, 2018 14:32
Get a list of OU with filter
function Format-DisplayList {
<#
.DESCRIPTION
Display an array larger than certain members into nice column(s) for
easy readability. Added the ability to either use a number system or dashes
to display the list.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,
@shinjijai
shinjijai / HP_Warranty_Functions.ps1
Last active April 20, 2021 11:57
Functions to use with HP's Warranty APIs
<#
.DESCRIPTION
Using HP's warranty API (beta) to get warranty information on computer system.
To use this script, a valid HP developer API is required, and have to be enrolled CSS (https://developers.hp.com/css-enroll).
#>
function Get-AuthorizationToken {
<#
.DESCRIPTION
Using the APIKey and APISecret, this will retrieve a token that'll be required for every call made to the developer API.
@shinjijai
shinjijai / Export-ComputerInfo.ps1
Last active December 6, 2018 19:22
Login script to collect the computer and monitor(s) serial number and other info
#Requires -Version 4
<#
.DESCRIPTION
This is to capture information use to get more accurate information for inventory.
.NOTES
Used as part of the login process, it'll try to get the following infomation in JSON:
{
"Manufacturer": "Microsoft Corporation",
@shinjijai
shinjijai / Import-ComputerInfo.ps1
Last active December 6, 2018 19:24
Using the files created by Export-ComputerInfo.ps1, export info to CSV
<#
.DESCRIPTION
This works with JSON files created by export_computerinfo.ps1
#>
$LogLocation = "\\samepath\as\export-computerinfo\"
$JSONFiles = Get-ChildItem -Path $LogLocation -Filter "*.json"
$FileName = "AllComputerInfo.csv"
$ReceiveAssetInfo = New-Object "System.Management.Automation.PSDataCollection[psobject]"
if($JSONFiles) {
$RunspacePool = [runspacefactory]::CreateRunspacePool(1,16)
@shinjijai
shinjijai / Export-RoomStatistics.ps1
Created June 19, 2018 12:42
Raw data dump of meetings for resource rooms
#Requires -Version 4.0
#Requires -modules ActiveDirectory
<#
.DESCRIPTION
This requires Exchange Web Service Managed API 2.2 tool which could be downloaded from
https://www.microsoft.com/en-us/download/details.aspx?id=42951.
.NOTES
Change the $From and $To to get a different date range information.This was created
to be ran manually, to get the raw data. The raw data should be imported into
@shinjijai
shinjijai / ReplicateServer.ps1
Last active July 25, 2018 13:04
Using RoboCopy to replicate a share from one server to another
<#
.DESCRIPTION
The process of copying and replicating the file server migration. Because RoboCopy is used, any files that are open will not be copied. So it'll be a good idea before making the file server switch to stop the shares on the old file server, and manually run the differential sync to make sure that all files are copied over.
.EXAMPLE
It's highly recommended that the intial sync should be done manually with the following:
.\replicateserver.ps1 -InitialCopy -SourceDirectory "\\Fileserver\Users" -DestinationDirectory "C:\Something" -LogLocation "C:\FileServerMove\Log" -LogName "Testing"
To schedule the subsequent differential syncs, set up a schedule task with the following: