Tags

Howto (51) Free Software (35) Powershell (33) Windows Server (23) AD (16) Hyper-V (16) Exchange (13) Office (13) Group Policy (10) Windows Server 2012 (9) Scripts (7) Symantec BE (5) Windows 8 (5) Cisco (4) TMG (4) Terminal Server (4) Cluster (3) HP (3) RDS (3) UAG (3) Citrix (2) DC (2) DNS (2) IE10 (2) OpenID (2) PKI (2) SCVMM (2) Windows Live (2) iLO (2) Backup (1) DPM (1) Fileserver (1) IE (1) SQL; DPM (1) Security (1) Sharepoint (1) Switch (1) VMWare (1) Veeam (1)

donderdag 24 juli 2014

Tip - Syntax Powershell highlighting toevoegen aan je Blog


 Deze fantastische tip, kwam ik tegen op het blog van DexterPOSH, zie ook:

http://dexterposh.blogspot.in/2014/06/tip-add-syntax-highlighting-for.html

Je moet de Powershell module "Copy to Colorized HTML" downloaden van:

http://en.community.dell.com/techcenter/powergui/m/script-add-ons/20439006.aspx

Vervolgens voeg je onderstaande code toe aan je ISE Profile (Microsoft.PowerShellISE_profile.ps1)

001
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(“Copy As Colorized HTML”,{Copy-ColorizedHTML},“Ctrl+Shift+C”)

Daarna kun je vanuit de ISE code naar HTML kopieren d.m.v. CTRL+SHIFT+C of vanuit het Add-ons menu.

Je hoeft daarna alleen nog maar de code te plakken in een nieuw blogger bericht en het kader eventueel wat verkleinen zodat het netjes op je blog terecht komt.

Export-FileStructure to CSV


Ik gebruik onderstaand script om de bestandsstructuur van een Powershell project in kaart te brengen, als onderdeel van de documentatie.

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
<#
.SYNOPSIS
   A CSV file will be created, which can be used for documentation i.a.
.DESCRIPTION
   Write log line into configured logfile. Set logfile in settings: Settings.Logfile.
.EXAMPLE
   Export-FileTree2CSV -Path "C:\Temp" -ExportFile test.csv -NumberOfLevelsDeep 10
.EXAMPLE
   Export-FileTree2CSV -Path "C:\Temp" -ExportFile 'C:\Test\test.csv'
.NOTES
   Written by Stein Salfischberger
#>

Function Export-FileTree2CSV
{
    [CmdletBinding()]
    Param (
# Geef hier de directory op welke je gedocumenteerd wilt hebben
        [Parameter(Mandatory=$True)][string] $Path
, # Geef hier de bestandsnaam (eventueel het gehele path) op van het te exporteren bestand (csv)
        [Parameter(Mandatory=$False)][string] $ExportFile = '..\tijdelijk\AckssPSFileStructure.csv'
, # Geen hier een getal op (integer) van het aantal niveaus diep
[Parameter(Mandatory=$False)][int] $NumberOfLevelsDeep = 10
    )

Get-ChildItem -Recurse -Path $Path | 
    ForEach-Object { $OutputRow = [ordered]@{ 0 = $_.PSIsContainer }; 
    $Elements = $_.FullName.Split('\'); 
    ForEach($Index in 1..$NumberOfLevelsDeep) { $OutputRow[[string]$Index] = $Elements[$Index] }; 
    New-Object PSCustomObject -Property $OutputRow } | 
    Export-Csv -Path $ExportFile -UseCulture -NoTypeInformation
}