Skip to content

Instantly share code, notes, and snippets.

View atao's full-sized avatar
🇲🇫

ATAO atao

🇲🇫
View GitHub Profile
@atao
atao / eject_random.ps1
Last active July 3, 2017 22:27
Open CD Drive in random time!
#PowerShell v3
#02/06/2016
Clear-Host
Sleep(1)
Write-Host " _______ ___ __ " -ForegroundColor DarkGreen
Sleep(1)
Write-Host "|#######| |###||##| " -ForegroundColor Green
Sleep(1)
Write-Host "|### ___| |###||__| " -ForegroundColor DarkGreen
Sleep(1)
$xml = [xml]@'
<Users>
<User Name="Foo">
<Friends>
<Friend Name="Bar"/>
</Friends>
</User>
<User Name="Foo2" />
<User Name="Foo3">
<Friends>
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Windows.Forms.Application]::EnableVisualStyles()
$Form = New-Object system.Windows.Forms.Form
$Form.Size = New-Object System.Drawing.Size(250,300)
$Form.Text = "Tools"
$Icon = New-Object system.drawing.icon ("C:\Program Files (x86)\ASUS\ASUS Smart Gesture\DesktopManager\resource\WindowStoreApp.ico")
$Form.Icon = $Icon
$Form.AutoSize = $True
@atao
atao / install_ocs.ps1
Last active November 29, 2016 14:25
Script d'installation de l'agent OCS Inventory pour un déploiement via GPO
##############################
# Installation OCS via GPO #
##############################
#Auteur : atao
#Date : 29/11/2016
#Chemin du fichier d'Installation
$executable = "\\[Chemin réseau de l'executable]\OCS-NG-Windows-Agent-Setup.exe"
#Récupération de la version du fichier
@atao
atao / iamroot.ps1
Created November 29, 2016 14:44
PowerShell is running with administrator rights?
#RunInAdmin?
([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
@atao
atao / Get-MSIFileInformation.ps1
Last active November 29, 2016 15:11
Get informations from MSI file.
#From http://www.scconfigmgr.com/2014/08/22/how-to-get-msi-file-information-with-powershell/
function Get-MSIFileInformation
{
param(
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[System.IO.FileInfo]$Path,
[parameter(Mandatory=$true)]
@atao
atao / encoding.ps1
Created December 2, 2016 09:33
Encoding in PowerShell
$OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@atao
atao / removeappxpackages.ps1
Created February 3, 2017 14:49
Windows - Remove Apps For Every User
$appname = @(
"*BingWeather*"
"*ZuneMusic*"
"*ZuneVideo*"
)
ForEach($app in $appname){
Get-AppxPackage -Name $app | Remove-AppxPackage -ErrorAction SilentlyContinue
}
@atao
atao / font_add.bat
Created April 24, 2017 10:01
Add font with GPO
net use x: "\\Path\fonts"
x:
xcopy /y *.ttf %systemroot%\fonts
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "font1 (TrueType)" /t REG_SZ /d "font1.ttf" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "font2 (TrueType)" /t REG_SZ /d "font2.ttf" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "font3 (TrueType)" /t REG_SZ /d "font3.ttf" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "font4 (TrueType)" /t REG_SZ /d "font4.ttf" /f
@atao
atao / RunAsAdmin.ps1
Last active October 1, 2023 19:34
🕵️ Self privileges escalation with PowerShell.
#Requires -RunAsAdministrator
#OneLine
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
#Or
$Loc = Get-Location
"Security.Principal.Windows" | % { IEX "( [ $_`Principal ] [$_`Identity ]::GetCurrent() ).IsInRole( 'Administrator' )" } | ? {
$True | % { $Arguments = @('-NoProfile','-ExecutionPolicy Bypass','-NoExit','-File',"`"$($MyInvocation.MyCommand.Path)`"","\`"$Loc\`"");
Start-Process -FilePath PowerShell.exe -Verb RunAs -ArgumentList $Arguments; } }