Skip to content

Instantly share code, notes, and snippets.

###############################################################################
## Custom Objects Create in C-Sharp
###############################################################################
$TargetDllPath = (Split-Path -parent $MyInvocation.MyCommand.Path) + "\PowerAlto2.dll"
$TestPath = (Split-Path -parent $MyInvocation.MyCommand.Path) + "\test.cs"
([System.Reflection.Assembly]::LoadWithPartialName("System.Xml")).Location
([System.Reflection.Assembly]::LoadWithPartialName("PowerAlto2")).Location
###############################################################################
VERBOSE: Loading module from path 'C:\_strap\poweralto2\poweralto2.psd1'.
VERBOSE: Loading 'Assembly' from path 'C:\_strap\poweralto2\PowerAlto2.dll'.
VERBOSE: Loading module from path 'C:\_strap\poweralto2\PowerAlto2.psm1'.
Add-Type : (0) : Source file 'C:\Windows\TEMP\vl5ovzf4.0.cs' could not be found
(1) : using System.Text.RegularExpressions;
At C:\_strap\poweralto2\PowerAlto2.psm1:13 char:1
+ Add-Type -ReferencedAssemblies @(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (error CS2001: S...ld not be found:CompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
Add-Type -ReferencedAssemblies @(
([System.Reflection.Assembly]::LoadWithPartialName("System.Xml")).Location,
([System.Reflection.Assembly]::LoadWithPartialName("System.Web")).Location,
([System.Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq")).Location
) -TypeDefinition @'
using System;
using System.Xml;
using System.Xml.Linq;
using System.Web;
using System.Text.RegularExpressions;
VERBOSE: Loading module from path 'C:\_strap\poweralto2\poweralto2.psm1'.
Add-Type : (0) : Source file 'C:\Windows\TEMP\e5ntpd5d.0.cs' could not be found
(1) : using System;
At C:\_strap\poweralto2\poweralto2.psm1:1 char:1
+ Add-Type -ReferencedAssemblies @(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (error CS2001: S...ld not be found:
CompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.
AddTypeCommand
function TestRegex {
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true,Position=0)]
[string]$Line,
[Parameter(mandatory=$true,Position=1)]
[regex]$Regex
)
ipmo dhcpserver
$DhcpServer = Read-Host "Dhcp Server?"
$Scopes = Get-DhcpServerv4Scope -ComputerName $DhcpServer
$ServerOptions = Get-DhcpServerv4OptionValue -ComputerName $DhcpServer
foreach ($s in $Scopes) {
foreach ($o in $ServerOptions) {
Set-DhcpServerv4OptionValue -OptionId $o.OptionId -Value $o.Value -ScopeId $s.ScopeId -ComputerName $DhcpServer
}
}
###############################################################################
#
# iSCSI Fixer
# Q1 2014
# brian.addicks@lockstepgroup.com
#
###############################################################################
#
$DiscoveryPortals = @("192.168.99.19"
param
(
[System.Management.Automation.CredentialAttribute()]
$Credential
)
# Changes the terminal profile from one setting to another when entering and exiting powershell.
# would be cool to add the ability to read the current profile when starting powershell so you can change back without manually defining it.
osascript -e 'tell application \"Terminal\" to set current settings of selected tab of front window to settings set \"Solarized PS\"'
Register-EngineEvent powershell.exiting -action { osascript -e 'tell application \"Terminal\" to set current settings of selected tab of front window to settings set \"Solarized Dark\"' -SupportEvent }
# got from http://mspowershell.blogspot.co.uk/2009/02/cli-menu-in-powershell.html?m=1
function DrawMenu {
## supportfunction to the Menu function below
param ($menuItems, $menuPosition, $menuTitel)
$fcolor = "Red"
$bcolor = "Black"
$l = $menuItems.length + 1
cls
$menuwidth = $menuTitel.length + 4