This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -Modules Pscx | |
# First load MS Office base assemblies into the environment | |
Add-Type -Path $env:WINDIR\assembly\GAC_MSIL\office\*\office.dll -PassThru # Use -PassThru to verify it worked (otherwise, fails silently) | |
# Then, add the target MS Word assembly | |
Get-ChildItem -Path $env:windir\assembly -Recurse -Filter Microsoft.Office.Interop.Word* -File | ForEach-Object { | |
Add-Type -LiteralPath ($_.FullName) -PassThru # PassThru again to verify | |
} | |
$wordApp = New-Object -ComObject Word.Application | |
if($null -eq $wordApp){ | |
Write-Host "Failed to create Word.Application object" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$winMergeExe = "$env:LOCALAPPDATA\Programs\WinMerge\WinMergeU.exe" | |
$oneDrivePaths = Get-Item -Path Env:\OneDrive* | Select-Object -Unique -ExpandProperty Value | |
# $duplicatePattern = New-Object -TypeName regex -ArgumentList @('(.+)(?:-[^-\s]+$|\.[^\.]+\.bak$)', [System.Text.RegularExpressions.RegexOptions]::Compiled,[timespan]::FromMilliseconds(100)) | |
$duplicatePattern = New-Object -TypeName regex -ArgumentList @("(.+)(?:-${env:COMPUTERNAME}(?:-\d+)*`$)", [System.Text.RegularExpressions.RegexOptions]::Compiled,[timespan]::FromMilliseconds(100)) | |
foreach($onedrive in $oneDrivePaths){ | |
Get-ChildItem -Path $onedrive -File -Recurse | Where-Object -FilterScript { $_.BaseName -match $duplicatePattern -and (Test-Path -Path (Join-Path -Path ($_.Directory.FullName) -ChildPath ($Matches[1] + $_.Extension)) -PathType Leaf)} | ForEach-Object { | |
$original = Join-Path -Path ($_.Directory.FullName) -ChildPath ($Matches[1] + $_.Extension) | |
$duplicate = $_.FullName | |
$originalHash = Get-FileHash - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -Assembly "System.Windows.Media.GlyphTypeface, PresentationCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" | |
#Requires -PSEdition Core | |
function Install-Font { | |
param | |
( | |
[Parameter(Mandatory,Position=0,ValueFromPipeline,ValueFromPipelineByPropertyName)] | |
[ValidateNotNullOrEmpty()] | |
[System.IO.FileInfo] | |
$FontPath | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -RunAsAdministrator | |
Get-ChildItem -Path 'HKCU:\SOFTWARE\Policies\Microsoft\MMC\' | ForEach-Object { Set-ItemProperty -Path $_.PSPath -Name Restrict_Run -Value 1 # Disable is 1 (1 means allow the MMC) | |
} | |
Set-ItemProperty -Path HKCU:\Software\Policies\Microsoft\MMC\ -Name RestrictAuthorMode -Value 0 | |
Set-ItemProperty -Path HKCU:\Software\Policies\Microsoft\MMC\ -Name RestrictToPermittedSnapins -Value 0 | |
if(Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun){ | |
Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun | |
} | |
Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name DisableRegistryTools -Value 0 -Force | |
Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\System\ -Name AllowDomainPINLogon -Value 1 -Type DWord |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Converts any text into acronym | |
function Get-Acronym | |
{ | |
<# | |
.SYNOPSIS | |
Converts a string into its acronym form. | |
.DESCRIPTION | |
This function "acronymize" a string given in entry | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Start-WinGetUpdate { | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory = $false, HelpMessage = "Decide if you want to skip the WinGet version check, default it set to false")] | |
[switch]$SkipVersionCheck = $false | |
) | |
#Check if script was started as Administrator | |
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) { | |
Write-Error ("{0} needs admin privileges, exiting now...." -f $MyInvocation.MyCommand) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Script:Timeout = 30 | |
# Suppose we need to do work on a list of files, and we want to show the user a progress bar | |
$files = Get-ChildItem -File | |
[scriptblock]$task = { | |
[CmdletBinding()] | |
param ( | |
[Parameter()] | |
[System.IO.FileSystemInfo] | |
$File | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Close-Elements | |
{ | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory, ParameterSetName="ReaderGiven", ValueFromPipeline, Position = 0)] | |
[ValidateNotNullOrEmpty()] | |
[System.Xml.XmlReader] $Reader, | |
[Parameter(Mandatory, ParameterSetName="InPathGiven", ValueFromPipeline, Position = 0)] | |
[ValidateNotNullOrEmpty()] | |
[string] $InPath, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#PSScriptInfo | |
.VERSION 1.0 | |
.GUID ed896e0c-b20d-4d70-b894-ac698a1032cb | |
.AUTHOR Mavaddat Javid | |
.COMPANYNAME Mav Jav Education |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! perl | |
# | |
# Mavaddat Javid (mavaddat.ca) 2023/03/21 | |
# derived from | |
# | |
# Mary Holstege ([email protected]) 2001/05/15 | |
# derived from | |
# | |
# Yuichi Koike ($Id: dtd2xsd.pl,v 1.2 2001/05/15 13:08:21 mholstege Exp $) | |
# derived from |