- <
- .SYNOPSIS
- This script gets all the exceptions you can trap by PowerShell
- .DESCRIPTION
- This script looks at all the loaded assemblies to get all
- the exceptions you can trap/catch using PowerShell. The
- display only covers those parts of the .NET framework are loaded.
- .NOTES
- File Name : Show-Exceptions.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh> .\Show-Exceptions.ps1 -Summary
- In 69 loaded assemblies, you have 418 exceptions:
-
- .EXAMPLE
- Psh> .\Show-Exceptions.ps1
- In 69 loaded assemblies, you have 418 exceptions:
-
- Name FullName
- ---- --------
- _Exception System.Runtime.InteropServices._Exception
- AbandonedMutexException System.Threading.AbandonedMutexException
- AccessViolationException System.AccessViolationException
- ...
-
-
-
- [CMDLETBINDING()]
- Param (
- [switch] $summary
- )
-
- $assemblies = [System.AppDomain]::CurrentDomain.GetAssemblies()
- $exceptions = $Assemblies | ForEach {
- $_.GetTypes() | where { $_.FullName -Match "System$filter.*Exception$" } }
-
-
- "In {0} loaded assemblies, you have {1} exceptions:" -f $assemblies.count, $exceptions.count
- If (-not $summary) {
- $Exceptions | sort name | format-table name, fullname
- }
Technorati Tags:
Exceptions
- <
- .SYNOPSIS
- This script reports on whether Lync should
- automatically start on a machine when a user
- logs in.
- .DESCRIPTION
- This script looks in the registry at a chosen machine
- to determine if the Lync client should automatically
- attempt to login when a user logs onto that system.
- .NOTES
- File Name : Get-LyncAutoLogonStatus
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- Lync 2010 or later
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh> .\Get-LyncAutoLogonStatus
- Automatically start Lync when I log on to Windows: True
-
-
-
- [Cmdletbinding()]
- Param (
- [string] $computer = "Cookham8.Cookham.net")
-
-
-
- $registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("CurrentUser", $computer)
- $key = $registry.OpenSubKey("SOFTWARE\Microsoft\Communicator", $True)
-
-
- Write-Host "Automatically start Lync when I log on to Windows:",`
- ([boolean] $key.GetValue("AutoRunWhenLogonToWindows",$null))
- <
- .SYNOPSIS
- This script defines a function that sets autologon
- .DESCRIPTION
- Autologon enables the system to logon after a reboot without
- you needing to enter credentials. This is an ideal scenario
- for lab or training room systems. This script defines
- a function that sets a userid/password and autologon.
- .NOTES
- File Name : Set-AdminLogon
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh> New-AdminLogon -user cookham\tfl -password 'JerryGarciaR0cks!'
- Auto logon created for [Cookham\tfl] with password: [JerryGarciaR0cks]
-
-
-
- Function New-AdminLogon {
-
- [cmdletbinding()]
- Param(
- [string] $User = $(Throw 'No user id specified'),
- [string] $Password = $(Throw 'No password specified')
- )
-
-
- $RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
-
-
- Set-ItemProperty -Path $RegPath -Name AutoAdminLogon -Value 1
-
-
- Set-ItemProperty -Path $RegPath -Name DefaultUserName -Value $User
- Set-ItemProperty -Path $regPath -Name DefaultPassword -Value $Password
-
-
- Write-Host ("Auto logon [{0}] set to password: [{1}]" -f $user, $password)
- }
-
- Set-AdminLogon -User 'Cookham\tfl' -Password 'JerryGarciaR0cks'
- <
- .SYNOPSIS
- This script defines a function that removes autologon
- .DESCRIPTION
- Autologon enables the system to logon after a reboot without
- you needing to enter credentials. This is an ideal scenario
- for lab or training room systems. This script defines
- a function that removes the autologon registry keys
- .NOTES
- File Name : Remove-AdminLogon
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh> Remove-AdminLogon
- Auto logon settings removed
-
- Function Remove-AdminLogon {
- [Cmdletbinding()]
- Param()
-
- $RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
-
- Remove-ItemProperty -Path $RegPath -Name AutoAdminLogon
-
- Remove-ItemProperty -Path $RegPath -Name DefaultUserName
- Remove-ItemProperty -Path $RegPath -Name DefaultPassword
-
- Write-Host ("Auto logon removed")
- }
- Remove-AdminLogon
- <
- .SYNOPSIS
- This script defines a function that sets autologon
- .DESCRIPTION
- Autologon enables the system to logon after a reboot without
- you needing to enter credentials. This is an ideal scenario
- for lab or training room systems. This script defines
- a function that sets a userid/password and autologon. It does NOT
- check to see if the value entries already exist.
- .NOTES
- File Name : Set-AutoAdminLogon
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh> Set-AutoAdminLogon -user cookham\tfl -password 'JerryGarciaR0cks!'
- Auto logon set for [Cookham\tfl] with password: [JerryGarciaR0cks]
-
-
-
- Function Set-AdminLogon {
-
- [cmdletbinding()]
- Param(
- [string] $User = $(Throw 'No user id specified'),
- [string] $Password = $(Throw 'No password specified')
- )
-
-
- $RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
-
-
- New-ItemProperty -Path $RegPath -Name AutoAdminLogon -Value 1 -EA 0
-
-
- New-ItemProperty -Path $RegPath -Name DefaultUserName -Value $User -EA 0
- New-ItemProperty -Path $regPath -Name DefaultPassword -Value $Password -EA 0
-
-
- Write-Host ("Auto logon set for [{0}] with password: [{1}]" -f $user, $password)
- }
-
- Set-AdminLogon -User 'Cookham\tfl' -Password 'JerryGarciaR0cks'
- <
- .SYNOPSIS
- This function converts a PPTx file into a PDF file
- .DESCRIPTION
- The Convert-PptxToPDF function first creates an
- instance of PowerPoint, opens the $ifile and saves
- this to $ofile as a PDF file.
- .NOTES
- File Name : Convert-PptxToPDF
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 3.0, Office 2010
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
-
- .EXAMPLE
- There is nothing to see, except a set of new PDF Files in the output folder
-
-
-
- Function Convert-PptxToPDF {
-
- [CmdletBinding()]
- Param(
- $IFile,
- $OFile
- )
-
-
- Add-type -AssemblyName office -ErrorAction SilentlyContinue
- Add-Type -AssemblyName microsoft.office.interop.powerpoint -ErrorAction SilentlyContinue
-
-
- $ppt = new-object -com powerpoint.application
- $ppt.visible = [Microsoft.Office.Core.MsoTriState]::msoFalse
-
-
-
- $pres = $ppt.Presentations.Open($ifile)
-
-
- $opt= [Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType]::ppSaveAsPDF
- $pres.SaveAs($ofile,$opt)
-
-
- $pres.Close()
- $ppt.Quit()
- $ppt=$null
-
- }
-
-
-
-
- $ipath = "E:\SkyDrive\PowerShell V3 Geek Week\"
-
- Foreach ($ifile in $(ls $ipath -Filter "*.pptx")) {
- # Build name of output file
- $pathname = split-path $ifile
- $filename = split-path $ifile -leaf
- $file = $filename.split(".")[0]
- $ofile = $pathname + $file + ".pdf"
-
-
- Convert-PptxToPDF -ifile $ifile -OFile $ofile
- }
- <
- .SYNOPSIS
- This script gets the current GUI mode of a Windows
- Server 2012 system, including current display resolution.
- .DESCRIPTION
- This script creates a custom object, then populates it
- with the current mode (Server Core, MinShell, Full Shell)
- and with the current resolution (resolution plus h/w). The
- display information object is then returned.
- .NOTES
- File Name : Get-GuiMode.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 3.0
- Windows Server 2012
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh> ./Get-GuiMode
- ComputerName : S1
- ServerCore : True
- FullServer : False
- MinShell : False
- Resolution : 1024x768
- Height : 768
- Width : 1024
-
-
-
-
- Function Get-GUIMode {
-
-
- $guimode = new-object psobject
-
-
- $guimode |Add-Member -MemberType NoteProperty -Name ComputerName -Value $(hostname)
-
-
-
- $sgs = (Get-WindowsFeature Server-Gui-Shell).Installed
- $mif = (Get-WindowsFeature Server-Gui-Mgmt-Infra).Installed
-
- If (!$sgs -and !$mif)
- {
- $guimode |Add-Member -MemberType NoteProperty -Name ServerCore -Value $True
- $guimode |Add-Member -MemberType NoteProperty -Name FullServer -Value $False
- $guimode |Add-Member -MemberType NoteProperty -Name MinShell -Value $False
- }
- Elseif ($sgs -and !$mif)
- {
- $guimode |Add-Member -MemberType NoteProperty -Name ServerCore -Value $False
- $guimode |Add-Member -MemberType NoteProperty -Name FullServer -Value $False
- $guimode |Add-Member -MemberType NoteProperty -Name MinShell -Value $True
- }
- Elseif ($sgs -and $mif)
- {
- $guimode |Add-Member -MemberType NoteProperty -Name ServerCore -Value $False
- $guimode |Add-Member -MemberType NoteProperty -Name FullServer -Value $True
- $guimode |Add-Member -MemberType NoteProperty -Name MinShell -Value $False
- }
-
-
- If ($rx=get-command Get-DisplayResolution) {
- $res = (Get-DisplayResolution)[0]
- $reslen = $res.length
- $r = [string]""
- for ($i = 0; $i -lt $reslen; $i++)
- {
- If ($res.substring($i,1) -ne "") { $r += $res.substring($i,1) }
- }
-
-
- $guimode |Add-Member -MemberType NoteProperty -Name Resolution -Value $r
-
- $h = $r.split("x")[1]
- $w = $r.split("x")[0]
-
- $guimode |Add-Member -MemberType NoteProperty -Name Height -Value $h
- $guimode |Add-Member -MemberType NoteProperty -Name Width -Value $w
- }
-
-
- $guimode
- }
-
-
- Get-GUiMode
- <#
- .Synopsis
- Creates a function to set PowerShell as GUI in Server 2012
- .DESCRIPTION
- The function in this script sets PowerShell as the
- default shell in Server 2012. When the server is rebooted,
- it runs PowerShell.exe by default. When PowerShell starts, it
- displays the $PSVersionTable variable.
- .NOTES
- File Name : Set-PowerShellAsGui.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : Server 2012
- .LINK
- This script posted to:
- http:
- .EXAMPLE
- Left as an exercise to the reader
- #>
-
-
- Function Set-PowerShellAsShell {
-
- [CmdletBinding()]
- Param (
- [switch] $Reboot = $false
- )
-
- # Create Registry Path variable
- $RegPath = "Microsoft.PowerShell.Core\Registry::"
- $RegPath += "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\"
- $RegPath += "Windows NT\CurrentVersion\winlogon"
-
- # Create splatted parameter hash table
- $parm = @{Path = $regpath} # key
- $parm += @{Name = 'Shell'} # value name
- $parm += @{Value = 'PowerShell.exe –NoExit
-Command "$psversiontable"'} # value’s value -
- # Set Registry value entry
- Set-ItemProperty @parm
-
- # And restart to see PowerShell
- if ($Reboot) {Restart-Computer -confirm}
- }
- <
- .SYNOPSIS
- This example shows how to create a new directory and
- subdirectory, and then delete only the subdirectory.
- .DESCRIPTION
- This sample is a re-write of an MSDN Sample,
- but in PowerShell. The sample firsts creates then removes
- a folder then looks to see what is left. The target
- folder is removed, but intermediate folders remain.
- .NOTES
- File Name : Show-FolderCreation.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library/62t64db3.aspx
- .EXAMPLE
- Psh> Show-FolderCreation.ps1
- Created: C:\NewDirectory\NewSubDirectory
- Deleted: C:\NewDirectory\NewSubDirectory
- Top-level directory exists: True
- Sub-directory exists : False
-
-
- [CmdletBinding()]
- Param (
- $Path = "C:\NewDirectory\NewSubDirectory"
- )
-
- Try
- {
-
- $result = [System.IO.Directory]::CreateDirectory($Path)
- "Created: $path"
- [System.IO.Directory]::Delete($Path)
- "Deleted: $path"
-
-
- $directoryExists = [System.Io.Directory]::Exists("C:\NewDirectory")
- $subDirectoryExists = [System.Io.Directory]::Exists($Path)
- "Top-level directory exists: $directoryExists"
- "Sub-directory exists : $subDirectoryExists"
- }
- Catch
- {
- "The process failed: {0}" -f $($error[0].Message)
- }
- <
- .SYNOPSIS
- This script contains a function, EchoArgs, that returns a list of
- the arguments passed and their type. It is used to demonstrate
- the use of the --% operator when calling a function or cmdlet, a new
- feature in PowerShell v3.
- .DESCRIPTION
- The EchoArgs function takes the arguments passed, via $args, and
- displays each argument and its type. Then, this function is called
- first with a normal calling sequence and then using --%.
- .NOTES
- File Name : EchoArgs.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library.
- .EXAMPLE
- Psh[Cookham8:C:\foo]>E:\PowerShellScriptLib\SERVER2012FEATURES\EchoArgs.ps1
- Calling Echoargs with 'fasdf $(LS) 2334 {asdf}'
- Argument [0]: [fasdf] Type:System.String
- Argument [1]: [System.Object[]] Type:System.Object[]
- Argument [2]: [2334] Type:System.Int32
- Argument [3]: [asdf] Type:System.Management.Automation.ScriptBlock
-
- Calling Echoargs with '--% asdf; {asfd}-a asdf'
- Argument [0]: [--%] Type:System.String
- Argument [1]: [asdf; $(ls) {asfd} - a asdf] Type:System.String
-
-
-
- Function EchoArgs {
-
- For ($i = 0; $i -ilt $Args.count; $i ++) {
- "Argument [{0}]: [{1}] Type:{2}" -f $I, $args[$i],$($args[$i].GetType().FullName)
- }
- }
-
-
- "Calling Echoargs with 'fasdf `$(LS) 2334 {asdf}'"
- Echoargs fasdf $(ls) 2334 {asdf}
- "";"Calling Echoargs with '--% asdf; {asfd}-a asdf'"
- Echoargs --% asdf; $(ls) {asfd} - a asdf
- <
- .SYNOPSIS
- This script defines a function, Disable-Gui which
- disables the GUI on Windows Server 2012 Server Core
- .DESCRIPTION
- The Disable-GUI function enables the GUI in Server 2012
- Server Core by Removing two windows features. The
- script add a Shell setting to ensure that when
- Server 2012 restarts, it starts with PowerShell.
- .NOTES
- File Name : Disable-GUI.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 3.0 and Windows Server 2012.
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh> Disable-GUI -Verbose
- Removing Windows Feature: Server-GUI-Shell, Server-Gui-Mgmt-Infra
- Setting Shell Registry setting to PowerShell
- Restarting the computer - please be patient
- < after reboot, full GUI is added >
-
-
- Function Disable-GUI {
-
-
-
-
- [Cmdletbinding()]
- Param()
-
-
- Write-Verbose "Removing Windows Feature: Server-GUI-Shell, Server-Gui-Mgmt-Infra"
- Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
-
-
- Write-Verbose "Setting Shell Registry setting to PowerShell"
- $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
- Set-ItemProperty -Path $RegPath -Name Shell -Value 'PowerShell.exe -noExit -Command "$psversiontable"' -Force
-
-
- Write-Verbose "Restarting the computer - please be patient"
- Restart-Computer
- }
- <
- .SYNOPSIS
- This script defines a function, Enable-Gui which
- enables the GUI on Windows Server 2012 Server Core
- .DESCRIPTION
- The Enable-GUI function enables the Gui in Server 2012
- Server Core by adding in two windows features. The
- script removes any Shell setting to ensure that when
- Server 2012 restarts, it starts with the full Desktop.
- .NOTES
- File Name : Enable-GUI.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 3.0 and Windows Server 2012.
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh> Enable-GUI -Verbose
- Installing Windows Feature: Server-GUI-Shell, Server-Gui-Mgmt-Infra
- Removing Shell Registry Setting
- Finished installation, now rebooting
- < after reboot, full GUI is added >
-
- Function Enable-GUI {
-
-
- [Cmdletbinding()]
- Param()
-
- Write-Verbose "Installing Windows Feature: Server-GUI-Shell, Server-Gui-Mgmt-Infra"
- Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra -Source d:\sources\sxs
-
- Write-Verbose 'Removing Shell Registry Setting'
- $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
- Remove-ItemProperty -Confirm -Path $RegPath -Name Shell -ErrorAction SilentlyContinue
-
- Write-Verbose "Finished installation, now rebooting"
- Restart-Computer
- }
- <
- .SYNOPSIS
- This script demonstrates setting default values for Local Hyper-V host.
- .DESCRIPTION
- This script imports the Hyper-V module then uses it
- to set certain default values for this hyper-V Host
- .NOTES
- File Name : Set-HyperVHostDefault.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 3.0 and Windows 8/Server 2012
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Left as an exercise for the reader
-
-
-
-
-
- Import-Module Hyper-V
-
- Write-Verbose "$((gcm -module hyper-v).Count) cmdlets imported in Hyper-V Module"
-
-
- $parm = @{}
-
-
- $parm += @{ComputerName = "Win8.Cookham.Net"}
-
-
- $parm += @{VirtualMachinePath = "E:\hyperv"}
-
-
- $parm += @{VirtualHardDiskPath = "E:\hyperv"}
-
-
- Write-Verbose "Setting parameters as follows:";$parm
- Set-VmHost @parm
-
-
-
- Get-VMHost
-
-
- <
- .SYNOPSIS
- This script demonstrates creating a Hyper-V Switch
- .DESCRIPTION
- This script imports the Hyper-V module then uses it
- to create an Internal Switch for use in future provisioning.
- .NOTES
- File Name : New-InternalSwitch.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 3.0 and Windows 8/Server 2012
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- C:\foo\> .New-InternalSwitch.ps1
- VERBOSE: New-InternalSwitch will create a new virtual network.
- Name SwitchType NetAdapterInterfaceDescription
- ---- ---------- ------------------------------
- Internal Internal
-
-
- Import-Module Hyper-V
- Try {New-VMSwitch -Name Internal -SwitchType Internal -ComputerName LocalHost -Verbose}
- Catch { "Failed to create switch"; $error[0] }
-
- <#
- .SYNOPSIS
- MSDN Sample Recoded in PowerShell demonstrating formatting
- .DESCRIPTION
- This sample recodes an MSDN Sample into PowerShell that
- shows some of the options of formatting using ToString() and
- various .NET formatting strings
- .NOTES
- File Name : Show-Formatting1.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http:
- MSDN sample posted to:
- http:
- .EXAMPLE
- Psh> .\Show-Formatting1.ps1\
- 00123
- 1.20
- 01.20
- 01,20
- 0.6
- 1,234,567,890
- 1.234.567.890
- 1,234,567,890.1
- 1,234.57
- #>
- ## Start script
- [double] $value = 123;
- $value.ToString("00000")
- # Displays 00123
- $value = 1.2;
- $value.ToString("0.00", [System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 1.20
- $value.ToString("00.00",[System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 01.20
- $value.ToString("00.00",
- [System.Globalization.CultureInfo]::CreateSpecificCulture("da-DK"))
- # Displays 01,20
- $value = .56
- $value.ToString("0.0", [System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 0.6
- $value = 1234567890
- $value.ToString("0,0", [System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 1,234,567,890
- $value.ToString("0,0",
- [System.Globalization.CultureInfo]::CreateSpecificCulture("el-GR"))
- # Displays 1.234.567.890
- $value = 1234567890.123456;
- $value.ToString("0,0.0", [System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 1,234,567,890.1
- $value = 1234.567890;
- $value.ToString("0,0.00", [System.Globalization.CultureInfo]::InvariantCulture)
- # Displays 1,234.57
- <
- .Synopsis
- This file contains two simple functions to manage the GUI
- in Server Core Windows Server 2012.
- .DESCRIPTION
- There are two functions: Enable-ServerCoreGui that enables
- the GUI in a server core installation. Diable-ServerCoreGuI
- disables the GUI and returns the installation to
- traditional Server Core.
-
- Enable-ServerCoreGui also checks to see if some or all
- parts are already installed andwarns accordingly.
- .EXAMPLE
- c:\foo> Enable-ServerCoreGui
-
- This enables the GUI and reboots the Server into FUll GUI mode.
-
- .EXAMPLE
- c:\foo> Disable-ServerCoreGui
-
- This disables the GUI and reboots the Server back to Server Core mode.
-
-
-
- Function Enable-ServerCoreGui {
-
-
- Import-Module -Name DISM -ErrorAction Stop
-
-
- if ((Get-WindowsOptionalfeature -online -Feature ServerCore-FullServer).state -eq 'Enabled'){
- "Servercore-FullServer is already enabled"
- }
-
- if ((Get-WindowsOptionalfeature -online -Feature Server-GUI-Shell).state -eq 'Enabled'){
- "Server-GUI Shell is already enabled"
- }
-
- if ((Get-WindowsOptionalfeature -online -Feature Server-Gui-Mgmt).state -eq 'Enabled'){
- "Server-Gui-Mgmt is already enabled"
- }
-
-
- Enable-WindowsOptionalFeature –Online -NoRestart `
- -Featurename ServerCore-FullServer, Server-Gui-Shell,Server-Gui-Mgmt
-
-
- Restart-computer
- }
-
- Function Disable-ServerCoreGui {
-
-
- Import-Module -Name DISM -ErrorAction Stop
-
-
-
- Disable-WindowsOptionalFeature –Online -NoRestart `
- -Featurename ServerCore-FullServer, Server-Gui-Shell,Server-Gui-Mgmt
-
-
- Restart-computer
- }
- <
- .SYNOPSIS
- This script shows the DNS Configuration of NICs
- in your system
- .DESCRIPTION
- This script is a re-write of an MSDN Sample
- using PowerShell./ The script gets all network
- active network interfaces then prints out that
- interfaces' DNS Properties.
- .NOTES
- File Name : Show-DnsConfiguration.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getallnetworkinterfaces.aspx
- .EXAMPLE
- Psh[C:\foo]> .\Show-DnsConfiguration.ps1
- Broadcom NetXtreme 57xx Gigabit Controller
- DNS suffix .............................. : cookham.net
- DNS enabled ............................. : False
- Dynamically configured DNS .............. : True
-
- ... more interfaces snipped for brevity!
-
-
-
- $adapters = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()
- ForEach ($adapter in $adapters) {
- $properties = $adapter.GetIPProperties()
- $adapter.Description
- " DNS suffix .............................. : {0}" -f $properties.DnsSuffix
- " DNS enabled ............................. : {0}" -f $properties.IsDnsEnabled
- " Dynamically configured DNS .............. : {0}" -f $properties.IsDynamicDnsEnabled
- }