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
Class MyPSObject : PSObject { | |
static [MyPSObject] op_Addition ([MyPSObject] $Object1, [MyPSObject] $Object2) { | |
<# | |
$obj1 = [mypsobject] @{a = 1} | |
$obj2 = [mypsobject] @{b = 2; c = 3} | |
$obj3 = [mypsobject] @{c = 0; d = 4} | |
$obj1 + $obj2 + $obj3 | |
a c b d |
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 Get-LoggedOnUser { | |
param( | |
[string[]] $ComputerName=$env:COMPUTERNAME | |
) | |
Begin { | |
$ErrorActionPreference = 'Stop' | |
& cmd /c ver | Out-Null | |
$encoding = [Console]::OutputEncoding | |
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding('utf-8') | |
} |
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 Get-FolderPath { | |
<# | |
.NAME | |
Get-FolderPath | |
.SYNOPSIS | |
This cmdlet retrieves the path to the folder on a vCenter Server system. | |
.DESCRIPTION | |
This cmdlet retrieves the path to the folder on a vCenter Server system. | |
.PARAMETER Folder | |
a folder on a vCenter Server system |
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 -Version 3.0 | |
<# | |
.SYNOPSIS | |
Wraps Invoke-WmiMethod to run a command async | |
.DESCRIPTION | |
Wraps Invoke-WmiMethod to run asynchronously on a number of computers | |
.PARAMETER Computer | |
An array of computers | |
.PARAMETER Command |
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 -Version 3.0 | |
<# | |
.SYNOPSIS | |
Log Archiver for Windows | |
.DESCRIPTION | |
This script can be used to archive old log files | |
.PARAMETER Path | |
The path to the directory with log files. | |
.PARAMETER ArchiveDays |
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
#!/usr/bin/perl -w | |
# | |
# This tool can be used to push inventory of virtual machines and ESXi hosts from a VIServer in GLPI via FusionInventory plugin | |
use v5.10; | |
use strict; | |
use warnings; | |
use VMware::VIRuntime; | |
use POSIX 'ceil'; |
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
$addressFamily = 'IPv4' | |
# Retrieve the network adapter | |
$adapters = Get-NetAdapter | Where-Object {$_.Status -eq 'Up'} | |
foreach ($adapter in $adapters) { | |
$ipConfiguration = $adapter | Get-NetIPConfiguration | |
if ($ipConfiguration.NetIPv4Interface.DHCP -eq 'Disabled') { | |
continue # 'DHCP is not enabled' | |
} | |
$dns = ($ipConfiguration | Get-DnsClientServerAddress -AddressFamily $addressFamily).ServerAddresses | |
# Remove any existing IPv4 IP and gateway from the adapter |
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
# 1. Remove lines containing only comments and empty lines | |
# 2. Remove a comment after some code, e.g. some code # a comment | |
# 3. Join a line with a trailing { to the next line, e.g. if (a condition) {$ | |
# 4. Join a line beginning with a } character to the previous line, e.g. ^}$, or ^ } | |
# 5. Replace the character ` when it is used to break code in two lines, with a space, e.g. somecode `$ | |
# 6. Replace all \r\n (carriage return and new line characters) with '; ' | |
$text = (Get-Content -Path .\SetStaticIP.ps1 | Where-Object {$_ -notmatch "^\s*?#|^$"} | ForEach-Object {$_.Trim()} | Out-String) ` | |
-replace '\s*?#.*?\r\n', '' ` | |
-replace '{\s*?\r\n\s*?', '{' ` |
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
#!/bin/sh | |
usage(){ | |
echo " | |
find non-ASCII characters in a string | |
Usage: $0 STRING | |
" | |
exit 0 | |
} |
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
[settings] | |
reposroot="/repo" | |
proxy="http://127.0.0.1:3128" | |
### EXAMPLE REPO CONFIG ### | |
# [reposlist] | |
# epel=true ### use reposync and createrepo | |
# centos-base=false ### use only createrepo | |
# vmtools="/opt/scripts/vmtools_osp_sync.sh" ### use a custom command |
NewerOlder