Display: Cloud | List
Most Popular Tags
Results (732 total) All > powershell (x)
First sample - recoded in PowerShell (Custom Numeric Format Strings)
[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$val
Last modified by Thomas Lee on 8/7/2012 5:58:28 PM
Copy Membership With Powershell (GroupPrincipal Class (System.DirectoryServices.AccountManagement))
param([Parameter(Position=0)][string]$FromIdentity, [Parameter(Position=1)][string]$ToIdentity, [Parameter(Position=2)][string]$Domain='somedefaultvalue')Add-Type -AssemblyName 'System.DirectoryServices.AccountManagement'$pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList Domain, $Domain$user = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindB
Last modified by Not4Got10 on 7/24/2012 3:29:56 PM
Tags:  powershell  scripting
Set Password From Powershell (AuthenticablePrincipal.SetPassword Method (System.DirectoryServices.AccountManagement))
param([Parameter(Position=0)][string]$User, [Parameter(Position=1)][string]$Password, [Parameter(Position=2)][string]$Domain='somedefaultvalue', [switch]$Expire)Add-Type -AssemblyName 'System.DirectoryServices.AccountManagement'$pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList Domain, $Domain$up = [System.DirectoryServices.AccountManagement.UserPrincipal]::
Last modified by Not4Got10 on 7/24/2012 3:22:57 PM
Tags:  powershell  scripting
GetAllNetworkInterfaces sample - rewritten in PowerShell (NetworkInterface.GetAllNetworkInterfaces Method (System.Net.NetworkInformation))
<#.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 sctipt gets all network active network interfaces then prints out that interfaces's DNS Properties..NOTES File Name : Show-DnsConfiguration.ps1 Author : Thomas Lee - tfl@psp.co.uk Requires : PowerShell Ve
Last modified by Thomas Lee on 4/30/2012 4:22:51 PM
Sample Reworked Using PowerShell (NetworkInterface Class (System.Net.NetworkInformation))
<#.SYNOPSIS This script, shows details about the Network Interfaces on a system. This is a re-write of an MSDN script into PowerShell.DESCRIPTION This script Uses several .NET classes to get the details of the interfaces on the system, then displays these details. Note in the MSDN Script, there were calls to other MSDN Samples. To make things simple, I have removed these c
Last modified by Thomas Lee on 4/30/2012 1:21:38 PM
Sample Show-NetworkInterfaces recoded in PowerShell (PhysicalAddress Class (System.Net.NetworkInformation))
<#.SYNOPSIS This script displays the NICs in a system and their physical address..DESCRIPTION This script is a MSDN Sample recoded in PowerShell. The script first gets all the interfaces on the system, then loops through them displaying more information about them to the console.Note the use of Console.Write in the loop at the end. Not quite sure a better PowerShell equivalient o
Last modified by Thomas Lee on 4/29/2012 2:27:09 PM
A simple PowerShell example of using the Parse method of the PhysicalAddress class (PhysicalAddress.Parse Method (System.Net.NetworkInformation))
$IPAddress = '10.10.10.1'Write-Host 'Test that the IP address works' $IP = Test-Connection -ComputerName $IPAddress -Count 1 -ErrorAction StopWrite-Host 'Get the mac address from arp'$Mac = (% arp -a $IP.Address)Write-Host 'Regex the output of Arp to get the mac address' $MacAddress = ($mac | ? { $_ -match $IP.Address } ) -match "([0-9A-F]{2}([:-][0-9A-F]{2}){5})"if ($Matches){ try {
Last modified by Thomas Lee on 4/29/2012 1:04:35 PM
Tags:  code  powershell  system.net
PowerShell syntax (SqlCommand.ExecuteReader Method (CommandBehavior) (System.Data.SqlClient))
Using a CommandBehavior member with PowerShell is done by a statc reference, e.g. $Rdr = $Cmd.ExecuteReader([System.Data.CommandBehavior]::SingleRow)
Last modified by Niels Grove-Rasmussen on 4/27/2012 1:04:05 PM
Improved Sample Format.PS1XML example (Defining Conditions for Displaying Data)
<?xml version="1.0" encoding="utf-8" ?><!-- Demo4.format.ps1xml Creates a list view to illustrate key aspects of a list view control--><Configuration><ViewDefinitions><View> <Name>CPUCost</Name> <ViewSelectedBy> <TypeName>System.Diagnostics.Process</TypeName> </ViewSelectedBy> <ListControl> <ListEnt
Last modified by Stanley Roark on 4/16/2012 4:21:21 PM
PowerShell (IAutomaticUpdates interface (Windows))
Here is a PowerShell script that will force the Windows Update agent to detect updates against the Microsoft Update servers. It will override any GPO settings in place, restart the Windows Update service, and force an update detection via the Windows Update Agent COM API. Remove-Item -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate -Force -Recurse -ErrorAction SilentlyContinue; Stop
Last modified by Thomas Lee on 4/2/2012 1:28:59 PM
Page view tracker