Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Dragan authored and Mateusz Dragan committed Jul 3, 2016
2 parents 9bf28e0 + 9339480 commit 2c1a58d
Show file tree
Hide file tree
Showing 99 changed files with 3,532 additions and 2,693 deletions.
2 changes: 1 addition & 1 deletion .localization-config
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
],
"includeDependencies": true,
"autoPush": true,
"useJavascriptMarkdownTransformer": false
"useJavascriptMarkdownTransformer": true
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ Walkthroughs and samples.

### *-tools
Scripts to automate Hyper-V/Windows Container things.

### Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
2 changes: 1 addition & 1 deletion demos/2015-Ignite-Whats-New/scripts/WorkloadSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function CreateBaseVM([string]$VMName, `
Get-iSCSITarget | Connect-iSCSITarget
Get-iSCSISession | Register-iSCSISession
Get-Disk | ?{$_.BusType -eq "iSCSI"} | %{
$d = WXYZ[$_.Number]
$d = "WXYZ"[$_.Number]
Set-Disk -Number $_.Number -IsReadOnly 0
Set-Disk -Number $_.Number -IsOffline 0
Initialize-Disk -Number $_.Number -PartitionStyle MBR
Expand Down
8 changes: 8 additions & 0 deletions hyperv-samples/benarm-powershell/GuestNameCheck.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Get the virtual machine name from the parent partition
<<<<<<< HEAD
$vmName = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").VirtualMachineName

# Replace any non-alphanumeric characters with an underscore
$vmName = [Regex]::Replace($vmName, "\W","_")

# Trim names that are longer than 15 characters
$vmName = $vmName.Substring(0, [System.Math]::Min(15, $vmName.Length))
=======
$vmName = (Get-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").VirtualMachineName
# Replace any non-alphanumeric characters with an underscore
$vmName = [Regex]::Replace($vmName,"\W","_")
# Trim names that are longer than 15 characters
$vmName = $vmName.Substring(0,[System.Math]::Min(15, $vmName.Length))
>>>>>>> 9339480bc30c0fc1ee0a1d9f34a6a2b4d9df5202

# Check the trimmed and cleaned VM name against the guest OS name
# If it is different, change the guest OS name and reboot
Expand Down
40 changes: 20 additions & 20 deletions hyperv-tools/Convert-WindowsImage/Convert-WindowsImage.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
$VhdPath = Join-Path -Path $VhdPath -ChildPath $vhdNameTemp
}

Write-Debug -Message " Temporary $VhdFormat path is: `$VhdPath`"
Write-Debug -Message " Temporary $VhdFormat path is: `"$VhdPath`""

#endregion Prepare variables

Expand All @@ -1600,7 +1600,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
{
$IsoFileName = Split-Path -Path $SourcePath -Leaf

Write-Verbose -Message "Copying ISO `$IsoFileName` to temp folder..."
Write-Verbose -Message "Copying ISO `"$IsoFileName`" to temp folder..."

# Robocopy.exe $(Split-Path $SourcePath -Parent) $TempDirectory $(Split-Path $SourcePath -Leaf) | Out-Null
$Item = Copy-Item -Path $SourcePath -Destination $TempDirectory -PassThru
Expand All @@ -1613,7 +1613,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
$IsoPath = ( Resolve-Path $SourcePath ).Path
$IsoFileName = Split-Path $IsoPath -Leaf

Write-Verbose -Message "Opening ISO `$IsoFileName`..."
Write-Verbose -Message "Opening ISO `"$IsoFileName`"..."
$openIso = Mount-DiskImage -ImagePath $IsoPath -StorageType "ISO" -PassThru

# Refresh the DiskImage object so we can get the real information about it. I assume this is a bug.
Expand All @@ -1623,7 +1623,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
$SourcePath = "$($driveLetter):\sources\install.wim"

# Check to see if there's a WIM file we can muck about with.
Write-Verbose -Message "Looking for `$SourcePath`..."
Write-Verbose -Message "Looking for `"$SourcePath`"..."

If (-Not ( Test-Path -Path $SourcePath ))
{
Expand Down Expand Up @@ -1717,7 +1717,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
$OpenImageFlags = $openImage.ImageFlags
$OpenImageVersion = $openImage.ImageVersion

Write-Verbose -Message "Image $OpenImageIndex selected: `$OpenImageFlags`..."
Write-Verbose -Message "Image $OpenImageIndex selected: `"$OpenImageFlags`"..."

# Check to make sure that the image we're applying is Windows 7 or greater.
If ($OpenImageVersion -lt $lowestSupportedVersion)
Expand Down Expand Up @@ -1876,10 +1876,10 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
}

# Create the Windows partition
Write-Verbose -Message "Creating Boot (`Windows`) partition..."
Write-Verbose -Message "Creating Boot (`"Windows`") partition..."
$windowsPartition = New-Partition -DiskNumber $disk.Number -UseMaximumSize -GptType '{ebd0a0a2-b9e5-4433-87c0-68b6b72699c7}'

Write-Verbose -Message " Formatting Boot (`Windows`) volume..."
Write-Verbose -Message " Formatting Boot (`"Windows`") volume..."
$windowsVolume = Format-Volume -Partition $windowsPartition -FileSystem NTFS -Force -Confirm:$false
}

Expand Down Expand Up @@ -1910,7 +1910,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
# Retreive access path for System partition.
$systemPartition = Get-Partition -UniqueId $systemPartition.UniqueId
$systemDrive = $systemPartition.AccessPaths[0].trimend("\").replace("\?", "??")
Write-Verbose -Message "System volume path: `$systemDrive`"
Write-Verbose -Message "System volume path: `"$systemDrive`""
}

# Assign drive letter to Boot partition. This is required for bcdboot
Expand Down Expand Up @@ -1944,12 +1944,12 @@ You can use the fields below to configure the VHD or VHDX that you want to creat

$windowsDrive = ( Get-Partition -Volume $windowsVolume ).AccessPaths[0].substring(0,2)

# This is to workaround No such drive exists error in PowerShell
# This is to workaround "No such drive exists" error in PowerShell
$Drive = Get-psDrive

$windowsDrive = ( Resolve-Path -Path $windowsDrive ).Path

Write-Verbose -Message "Boot volume path: `$windowsDrive`. (Took $attempts attempt(s) to assign.)"
Write-Verbose -Message "Boot volume path: `"$windowsDrive`". (Took $attempts attempt(s) to assign.)"

#endregion Create and partition VHD

Expand Down Expand Up @@ -2310,7 +2310,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
# ISSUE - do we want VL here?

$vhdFinalName = "$($buildLabEx)_$($skuFamily)_$($editionId)_$($openImage.ImageDefaultLanguage).$($VhdFormat.ToLower())"
Write-Debug -Message " $VhdFormat final name is: `$vhdFinalName`"
Write-Debug -Message " $VhdFormat final name is: `"$vhdFinalName`""
}

If ($hyperVEnabled)
Expand All @@ -2327,18 +2327,18 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
$vhdParentPath = Split-Path -Path $VhdPath -Parent
$vhdFinalPath = Join-Path -Path $vhdParentPath -ChildPath $vhdFinalName

Write-Debug -Message " $VhdFormat final path is: `$vhdFinalPath`"
Write-Debug -Message " $VhdFormat final path is: `"$vhdFinalPath`""

If (Test-Path -Path $vhdFinalPath)
{
$VhdNameOld = Split-Path -Path $vhdFinalPath -Leaf

Write-Verbose -Message "Deleting pre-existing $($VhdFormat): `$VhdNameOld`..."
Write-Verbose -Message "Deleting pre-existing $($VhdFormat): `"$VhdNameOld`"..."

Remove-Item -Path $vhdFinalPath -Force
}

Write-Debug -Message " Renaming $VhdFormat at `$VhdPath`."
Write-Debug -Message " Renaming $VhdFormat at `"$VhdPath`"."

$VhdPathFull = ( Resolve-Path -Path $VhdPath ).Path

Expand All @@ -2355,7 +2355,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
{
Write-Verbose -Message ( [system.string]::Empty )
Write-Error -Message $PSItem
Write-Verbose -Message "Log folder is `$logFolder`"
Write-Verbose -Message "Log folder is `"$logFolder`""
}
Finally
{
Expand Down Expand Up @@ -4242,7 +4242,7 @@ VirtualHardDisk
Add-Type -TypeDefinition $code -ReferencedAssemblies "System.Xml","System.Linq","System.Xml.Linq" -ErrorAction SilentlyContinue
}

# This is required for renewed Mount-RegistryHive and Dismount-RegistryHive
# This is required for renewed "Mount-RegistryHive" and "Dismount-RegistryHive"
# functions using Windows API. Code borrowed from
# http://www.leeholmes.com/blog/2010/09/24/adjusting-token-privileges-in-powershell/

Expand Down Expand Up @@ -4551,7 +4551,7 @@ Start-Executable
$SuccessfulErrorCode = 0
)

Write-Debug -Message " Running `$Executable` with parameters: `$Arguments`"
Write-Debug -Message " Running `"$Executable`" with parameters: `"$Arguments`""

$StartProcessParam = @{

Expand Down Expand Up @@ -4647,10 +4647,10 @@ Import-ModuleEx

# When we have $VerbosePreference defined as "Continue" and import
# a module (either implicitly, by firt use, or explictily, calling
# Import-Module), there's a lot of Verbose output listing every cmdlet
# "Import-Module"), there's a lot of Verbose output listing every cmdlet
# and every function. This output provides no value, thus we need
# to suppress it. Unfortunately, even if we pass -Verobse:$False
# to Import-Module, it only helps to swallow the list of cmdlets.
# to suppress it. Unfortunately, even if we pass "-Verobse:$False"
# to "Import-Module", it only helps to swallow the list of cmdlets.
# The list of functions is still thrown to output. (This is probably
# a bug). Thus, we need to temporary change $VerbosePreference.

Expand Down
Loading

0 comments on commit 2c1a58d

Please sign in to comment.