Create ISO file with powershell

Create a file with name createiso.ps1 and fill this code into it.

function New-IsoFile 
  <# .Synopsis Creates a new .iso file .Description The New-IsoFile cmdlet creates a new .iso file containing content from chosen folders .Example New-IsoFile "c:\tools","c:Downloads\utils" This command creates a .iso file in $env:temp folder (default location) that contains c:\tools and c:\downloads\utils folders. The folders themselves are included at the root of the .iso image. .Example New-IsoFile -FromClipboard -Verbose Before running this command, select and copy (Ctrl-C) files/folders in Explorer first. .Example dir c:\WinPE | New-IsoFile -Path c:\temp\WinPE.iso -BootFile "${env:ProgramFiles(x86)}\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\efisys.bin" -Media DVDPLUSR -Title "WinPE" This command creates a bootable .iso file containing the content from c:\WinPE folder, but the folder itself isn't included. Boot file can be found in Windows ADK. Refer to IMAPI_MEDIA_PHYSICAL_TYPE enumeration for possible media types: .Notes NAME: New-IsoFile AUTHOR: Chris Wu LASTEDIT: 03/23/2016 14:46:50 #> 
    [parameter(Position=1,Mandatory=$true,ValueFromPipeline=$true, ParameterSetName='Source')]$Source,  
    [parameter(Position=2)][string]$Path = "$env:temp\$((Get-Date).ToString('yyyyMMdd-HHmmss.ffff')).iso",  
    [ValidateScript({Test-Path -LiteralPath $_ -PathType Leaf})][string]$BootFile = $null, 
    [string]$Title = (Get-Date).ToString("yyyyMMdd-HHmmss.ffff"),  
  Begin {  
    ($cp = new-object System.CodeDom.Compiler.CompilerParameters).CompilerOptions = '/unsafe' 
    if (!('ISOFile' -as [type])) {  
      Add-Type -CompilerParameters $cp -TypeDefinition @'
public class ISOFile  
  public unsafe static void Create(string Path, object Stream, int BlockSize, int TotalBlocks)  
    int bytes = 0;  
    byte[] buf = new byte[BlockSize];  
    var ptr = (System.IntPtr)(&bytes);  
    var o = System.IO.File.OpenWrite(Path);  
    var i = Stream as System.Runtime.InteropServices.ComTypes.IStream;  
    if (o != null) { 
      while (TotalBlocks-- > 0) {  
        i.Read(buf, BlockSize, ptr); o.Write(buf, 0, bytes);  
      o.Flush(); o.Close();  
    if ($BootFile) { 
      if('BDR','BDRE' -contains $Media) { Write-Warning "Bootable image doesn't seem to work with media type $Media" } 
      ($Stream = New-Object -ComObject ADODB.Stream -Property @{Type=1}).Open()  # adFileTypeBinary 
      $Stream.LoadFromFile((Get-Item -LiteralPath $BootFile).Fullname) 
      ($Boot = New-Object -ComObject IMAPI2FS.BootOptions).AssignBootImage($Stream) 
    Write-Verbose -Message "Selected media type is $Media with value $($MediaType.IndexOf($Media))"
    ($Image = New-Object -com IMAPI2FS.MsftFileSystemImage -Property @{VolumeName=$Title}).ChooseImageDefaultsForMediaType($MediaType.IndexOf($Media)) 
    if (!($Target = New-Item -Path $Path -ItemType File -Force:$Force -ErrorAction SilentlyContinue)) { Write-Error -Message "Cannot create file $Path. Use -Force parameter to overwrite if the target file already exists."; break } 
  Process { 
    if($FromClipboard) { 
      if($PSVersionTable.PSVersion.Major -lt 5) { Write-Error -Message 'The -FromClipboard parameter is only supported on PowerShell v5 or higher'; break } 
      $Source = Get-Clipboard -Format FileDropList 
    foreach($item in $Source) { 
      if($item -isnot [System.IO.FileInfo] -and $item -isnot [System.IO.DirectoryInfo]) { 
        $item = Get-Item -LiteralPath $item
      if($item) { 
        Write-Verbose -Message "Adding item to the target image: $($item.FullName)"
        try { $Image.Root.AddTree($item.FullName, $true) } catch { Write-Error -Message ($_.Exception.Message.Trim() + ' Try a different media type.') } 
  End {  
    if ($Boot) { $Image.BootImageOptions=$Boot }  
    $Result = $Image.CreateResultImage()  
    Write-Verbose -Message "Target image ($($Target.FullName)) has been created"

After file creation, you must import this module to your open powershell session.

Import-Module .\createiso.ps1

Now you can define on powershell your source folder

$source_dir = "Z:\isofilel\"

We can create our ISO file
get-childitem "$source_dir" | New-ISOFile -path C:\iso\mydmz.iso

Export and Import AD Groups

Get Group from AD
Get-QADGroupMember oldMoep\WRF-universal | select ntaccountname > C:\ad\WRF-universal.txt

Remove spaces
get-Content .\WRF-universal.txt | Foreach {$_.TrimEnd()} | Set-Content .\WRF-universal1.txt
Import TXT into AD Groups
Get-Content .\WRF-universal1.txt | Add-QADGroupMember -identity Moep\WRF-universal

powershell suchen und ersetzen in datei in unterordner

Morgen Zusammen,

wie mache ich so etwas am besten?

Per Notepad++ geht so etwas auch

Per Powershell geht so etwas auch

$txtFiles=get-childitem C:test *.xml -recurse
foreach ($file in $txtFiles)
(Get-Content $file.PSPath) |
Foreach-Object {$_ -replace “Wolf”, “Katze} |
Set-Content $file.PSPath

Replacing Strings in Multiple Files in Folder and SubFolders

Sammel Links zu interessanten Themen der IT

Reset Outlook Foldernames in OWA

What happens to Outlook 2010 Mailtips if client is offline

Powershell and SQL commands / SQL transactions

Group Policies, Group Policy Preferences, Tattooing

Outlook 2010 Autocomplete

Windows Active Directory Group Membership Limitation

Reset Active Directory User Password with Powershell

Boot Logging with Sysinternals Process Monitor

Remove Saved or Cached Network Passwords on Windows 7 or Windows 2008 R2
Das Tool klist sehr gut ist um Keberos Anmeldungen zu kontrollieren

Exchange Server Caches and Their Lifetimes

Calendar Checking Tool for Outlook (CalCheck)

Microsoft Exchange PST Capture 2.0