-
Notifications
You must be signed in to change notification settings - Fork 1
Misc Scripts
Atiq Rahman edited this page Nov 27, 2024
·
5 revisions
Open an editor elevated mode to access a file that only admin has permission on,
Start-Process $EditorProgram -Verb Runas -ArgumentList $hostsFilePath -ErrorAction 'stop'
Deprecated by Expand-Archive
(in PS 5.1 or higher).
unzip.ps1
with ref, howtogeek
function Expand-ZIPFile($file, $destination)
{
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}
Expand-ZIPFile "D:\Soft\Drivers.zip" "D:\Soft\Drivers"
Set-VSEnvironment.ps1
Created 2011 Jun
pushd
cd "C:\ProgData\Microsoft Visual Studio 10.0\Common7\Tools"
.\vsvars32.bat
popd
pacman-timer.ps1
from 2015-03
SVN Pacman timer for reference, to find time difference
# Small classic
& 'C:\Python27\ArcGISx6410.2\python.exe' pacman.py -p AlphaBetaAgent -l smallClassic -a depth=4 -k 2
$StartDate=(GET-DATE)
& 'C:\Python27\ArcGISx6410.2\python.exe' pacman.py -p AlphaBetaAgent -l smallClassic -a depth=4 -k 2
$EndDate=(GET-DATE)
NEW-TIMESPAN –Start $StartDate –End $EndDate
# cmd variations
# test classic
# & 'C:\Python27\ArcGISx6410.2\python.exe' pacman.py -p ReflexAgent -l testClassic
# Medium classic
# & 'C:\Python27\ArcGISx6410.2\python.exe' pacman.py -p ReflexAgent -l MediumClassic -k 2
apply-settings.ps1
contents follow,
<#
.SYNOPSIS
Manage console shortcut setting
.DESCRIPTION
Updated 2013 and 2014
Apply settings for the changes made in saconsole.lnk and Windows Powershell Profile
.EXAMPLE
.NOTES
Modulized version to reduce size of Init script.
Deprecated
Not seeing anything to publish from this one.
Demos
- if else block
#>
if ($args.Count -gt 1)
{
echo "Wrong number of arguments."
break
}
if ($args.Count -eq 0) {
$cmdswitch = "garbage"
}
else {
$cmdswitch = $args[0]
}
if ($cmdswitch.Equals("toggle")) {
# Bakup
echo "Storing info back to script dir."
if ( -not (Test-Path $env:PS_SC_DIR\Bakup)) { md $env:PS_SC_DIR\Bakup }
#backup saconsole.lnk and copy
mv -Force $env:PS_SC_DIR/saconsole.lnk $env:PS_SC_DIR/Bakup
cp $env:windir/saconsole.lnk $env:PS_SC_DIR
<# This part is currently deprecated
backup profile and copy
if (Test-Path $env:PS_SC_DIR/Bakup/WindowsPowerShell) { rd -Recurse -Force $env:PS_SC_DIR/Bakup/WindowsPowerShell }
mv -Force $env:PS_SC_DIR/WindowsPowerShell $env:PS_SC_DIR/Bakup
cp -Recurse $env:userprofile/Documents/WindowsPowerShell $env:PS_SC_DIR#>
}
# Powershell `elseif` instead of else if
elseif ($cmdswitch.Equals("garbage")) {
# Bakup
echo "Applying script settings into system."
if ( -not (Test-Path $env:PS_SC_DIR\Bakup)) { md $env:PS_SC_DIR\Bakup }
if (Test-Path $env:PS_SC_DIR/Bakup/saconsole.lnk) { mv -Force $env:windir/saconsole.lnk $env:PS_SC_DIR/Bakup/saconsole.lnk }
cp $env:PS_SC_DIR/saconsole.lnk $env:windir
#backup profile and copy
if (Test-Path $env:PS_SC_DIR/Bakup/WindowsPowerShell) { rd -Recurse -Force $env:PS_SC_DIR/Bakup/WindowsPowerShell }
if (Test-Path $env:userprofile/Documents/WindowsPowerShell) { cp -Recurse -Force $env:userprofile/Documents/WindowsPowerShell -Destination $env:PS_SC_DIR/Bakup }
cp -Recurse $env:PS_SC_DIR/WindowsPowerShell $env:userprofile/Documents/
rd -Recurse -Force $env:userprofile/Documents/WindowsPowerShell/.svn
}
else {
echo "Wrong cmd argument"
}