Skip to content

Instantly share code, notes, and snippets.

View tdewin's full-sized avatar

tdewin

View GitHub Profile
$apps = @('viber','skype','lync','outlook','spotify')
$forceclose = @()
$procs = get-process
foreach($kp in $apps) {
$procs | ? { $_.name -imatch $kp } | % {
$proc = $_
$result = $proc.CloseMainWindow()
if ($result -eq $false) {
$forceclose += $proc
@tdewin
tdewin / vbopsrest.ps1
Created September 12, 2017 17:35
VBO365 Rest API testing with powershell
#ignore self signed
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
@tdewin
tdewin / add-adoutovbo365.ps1
Last active November 29, 2017 08:54
Add Users from an OU to VBO365
## variables to set
$ad = "mydomain.com"
$cred = Get-Credential -UserName "administrator" -Message "AD"
$ouname = "My OU"
$orgname = "exchange.mydomain.com"
$reponame = "Default Backup Repository"
##
function New-VBOOUJob {
function start-vbomanuallmount {
if ($(Get-Module -Name Veeam.Archiver.PowerShell) -eq $null) {
$installpath = Get-ItemPropertyValue -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Veeam.Archiver.Service' -Name ImagePath -ErrorAction SilentlyContinue
if ($installpath -ne $null) {
$modulepath = Join-Path -Path (split-Path -Parent ($installpath -replace '"', "")) -ChildPath "Veeam.Archiver.PowerShell"
write-verbose "Loading VBO module from : $modulepath"
Import-module $modulepath
}
}
$prx = Get-VBOProxy
@tdewin
tdewin / md5hash-text.ps1
Created July 9, 2018 10:39
Calculate md5 hash of text
function md5text { param($text) ([System.Security.Cryptography.MD5]::Create().ComputeHash([System.Text.Encoding]::UTF8.GetBytes($text))| % {$_.toString("x2") }) -join ""}
@tdewin
tdewin / fileretentioncheck.ps1
Created July 11, 2018 08:20
Check retention of Veeam files and do something with it
$retDays = 14
$path = "c:\myrepository\"
$prevDate = (get-date).AddDays(-$retDays)
$filesDir = get-childitem -Path $path -Recurse -Include "*.vbk","*.vib" -File
$listrm = @()
foreach ($file in $filesDir) {
$fname = $file.FullName
@tdewin
tdewin / Microsoft.PowerShell_profile.ps1
Created August 14, 2018 07:50
vSphere CLI RDP Manager in $profile
function Get-VSPLabConnection {
param(
$profilespath="HKCU:\Software\vSpshereConnections",
$address=""
)
$entries = @(Get-ItemProperty -Path $profilespath)
if ($entries.count -gt 0) {
$procentries = @()
foreach($entry in ($entries | Get-Member | ? { $_.name -match "@$address" } | % { $_.Name })) {
$item = Get-ItemPropertyValue -Path $profilespath -name $entry
@tdewin
tdewin / cleanup.ps1
Created August 30, 2018 18:39
Clean up demo product install
$prod = "myapp"
while ($($t = get-process | ? { $_.Name -match $prod }; $t -ne $null)) { $t | Stop-Process -Force;sleep -Seconds 1 }
$apps = Get-WmiObject -Class Win32_Product | Where-Object {
$_.Name -match $prod
}
foreach($app in $apps) {
$app.Uninstall();
}
@tdewin
tdewin / move-vboentitydata-sample.ps1
Created September 25, 2018 14:11
Move-VBOEntityData sample
$repo2y = Get-VBORepository -Name repo2y
$repoinf = Get-VBORepository -Name repoinf
$alex = Get-VBOEntityData -Type User -Repository $repo2y -Name "Alex Wilber"
$alex
Move-VBOEntityData -From $repo2y -To $repoinf -User $alex
#auto install
<# plan_vbo365.json sample :
{
"license": { "src":"veeam_backup_microsoft_office_nfr_50.lic" },
"steps": [
{
"src":"Veeam.Backup365_2.0.0.567.msi",
"install":"__file__",
"arguments":[
"/qn",