Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@altrive
altrive / PSError.ps1
Last active December 14, 2015 05:29
特定条件下でPowerShellでマウントしたISOイメージにアクセスできなくなる問題。
#Can't Access mounted ISO Image PSDrive
<#
概要:
Dismount-DiskImage コマンドはマウントされていないISOイメージに対して呼出しても特にエラーは発生しない。
ただ、特定の条件が重なった場合に、マウントしたPSドライブにアクセスできない問題が発生することを確認。
問題が発生した場合はPowerShellのRunSpaceの再起動が必要となる?
再現条件:
1. Dismount-DiskImage を 2回以上呼出
@altrive
altrive / Copy-WindowsImageSxS.ps1
Last active December 14, 2015 17:39
Windows Server 2012のWinSxSフォルダをインストールメディアから抽出、指定のディレクトリにコピーするPowerShellコマンドです。 インターネット未接続環境において、ディスク上から削除されている機能をインストールする際にこのWinSxsフォルダが必要となります (例:ServerCoreへの機能追加等) WIMイメージのマウント(Mount-WindowsImage)は時間がかかるので、事前にWinSxSフォルダを抽出しネットワーク共有にコピーしておくと便利です。
<#
.Synopsis
Extract WinSxS data from Windows Image and copy to destination folder
.Description
WinSxS is used to enable Windows features which removed from disk.
In offline environment. Enable feature in ServerCore installation need
WinSxS data that included in full installer image.
WIM extract takes long times operation
@altrive
altrive / New-VyattaVM.ps1
Last active February 7, 2016 13:32
Create Vyatta VirtualMachine on Hyper-V. Vyatta configuration is loaded from virtual floppy(.vfd)
function New-VyattaVM
{
[Cmdletbinding()]
param(
[string]$VmName,
[string]$ExternalSwitchName,
[string]$InternalSwitchName,
[string]$VyattaLiveCDPath,
[string]$VyattaConfigVfdPath
)
@altrive
altrive / New-OSBaseImage.ps1
Last active September 27, 2022 16:07
PowerShell script to create OS Base VHD for Windows 8/Windows Server2012
#Create OS BaseImage VHD
function New-OSBaseImage
{
[Cmdletbinding()]
param(
$VhdPath,
$OSImageName,
$MediaPath,
$VhdConfig,
$DismConfig,
@altrive
altrive / Get-WindowsUpdateFileList.ps1
Last active November 12, 2019 16:23
PowerShell cmdlets to get WindowsUpdate patch file List.
#Requires –Version 3
#Get WindowsUpdate List for offline patch
function Get-WindowsUpdateFileList
{
param(
[Parameter(Mandatory=$True)]
[string] $Filter
)
$objSession = New-Object -ComObject "Microsoft.Update.Session"
@altrive
altrive / Add-WindowsDefenderExclusionsPolicy.ps1
Last active June 21, 2023 18:14
Add WindowsDefender exclusions policies for Windows 8 Hyper-V
function Add-WindowsDefenderExclusionsPolicy
{
$ErrorActionPreference="Stop"
Set-StrictMode -Version Latest
#Get Hyper-V Settings
$vmHost = Get-VMHost
#Default Exclusion Entries
$excludes = @{
@altrive
altrive / Install-VisualStudio.ps1
Last active March 29, 2024 14:27
Unattend install script for Visual Studio 2012 and Visual Studio 2012 Update 2
function Install-VisualStudio
{
[CmdletBinding()]
param (
[string] $ImagePath,
[string[]] $ArgumentList,
[string] $InstallPath,
[string] $ProductKey
)
Write-Verbose "Install Visual Studio 2012..."
@altrive
altrive / Install-ManagementStudio.ps1
Last active December 15, 2015 21:39
SQL Server 2012 SP1 Express Management Studio unattend offline installer.
function Install-ManagementStudio
{
[CmdletBinding()]
param(
$ImagePath,
$WinSxS
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
@altrive
altrive / Test-RebootRequired.ps1
Last active August 3, 2023 14:34
Check pending reboot on local computer
#Based on <http://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542>
function Test-RebootRequired
{
$result = @{
CBSRebootPending =$false
WindowsUpdateRebootRequired = $false
FileRenamePending = $false
SCCMRebootPending = $false
}
@altrive
altrive / Install-SysInternalsTool.ps1
Last active March 18, 2024 12:26
Install and setup script for SysInternals tools(BGInfo/AutoLogon).
#Install SysInternals BGInfo/AutoLogon tools
function Install-SysInternalsTool
{
#Target directory is %WinDir%C:\Windows\System32\SysInternals
$targetDir = Join-Path $env:WinDir "System32\SysInternals"
#Tools to be downloaded
$tools = @{
Bginfo = "http://live.sysinternals.com/Bginfo.exe"
Autologon = "http://live.sysinternals.com/Autologon.exe"