2012/11/01

Create a bunch of DNS Entries using PowerShell and DNScmd.exe

Today I needed to create approx. ~50 DNS A entries.
Each of those also need to have a PTR entry.

Lazy as i am... a quick search for PowerShell DNS module did return some interesting things but none who can create both A and PTR DNS entries at the same time.

So I decided to finally use DNSCMD.exe (full syntax on technet) with powershell.

Requirement: DNSCmd.exe is part of the DNS Server Tools and need to be installed prior to use it. On Windows server you can install it using Add-WindowsFeature RSAT-ADDS-Tools


Here is a quick syntax overview of the Dnscmd.exe that we will be using.

dnscmd.exe <DNSServer> /RecordAdd <DNSZone> <NewEntryName> /CreatePTR A <IPAddress>


First Step: Create a CSV with all the information (in Excel or via PowerShell)
here is an example, save it as DNSEntries.csv (in my case at the root of the C: drive)


Second Step: The Script OneLiner:
Import-CSV -Path "c:\DNSEntries.csv" | ForEach-Object { dnscmd.exe $_.dnsserver /RecordAdd $_.zone $_.name /createPTR $_.type $_.IP }


The output should look like this

2012/10/21

How to report a bug or give a suggestion to the #powershell team ?


Just a reminder to myself..., if you find a bug on #PowerShell or if you have a suggestion, here is the link

https://connect.microsoft.com/PowerShell/SearchResults.aspx?FeedbackType=0&Scope=0&SortOrder=5

2012/09/22

PowerShell Resources - From Noob to Ninja

Videos
Windows PowerShell for Beginners
Technet ScriptCenter - Windows PowerShell: Learn It Now Before It's an Emergency

Build2011 - Windows networking with PowerShell: A foundation for data center management
TechEd 2011 - Advanced Automation Using Windows PowerShell 2.0
TechEd 2011 - Windows PowerShell Remoting: Definitely NOT Just for Servers
TechEd 2012 - Windows PowerShell Crash Course
TechEd 2012 - Advanced Automation Using Windows PowerShell 3.0
TechEd 2012 - The Dirty Dozen: Windows PowerShell Scripts for the Busy DBA
TechEd 2012 - Inside Windows Server 2012 Multi-Server Management Capabilities
TechEd 2012 - Group Policy Reporting and Analysis with Windows PowerShell
Technet Radio - The Scripting Guy’s Top 5 PowerShell 3.0 Tips and Tricks
More videos on http://channel9.msdn.com

Guides
Windows PowerShell Survival Guide (en-US) Extensive list of resources on PowerShell
Windows PowerShell 3.0 and Server Manager Quick Reference Guides
Ravikanth Chaganti - WMI Query Language via PowerShell
Don Jones - Secrets of PowerShell Remoting
Windows PowerShell Core About Topics



Code repository
PoshCode
Technet Gallery - Script Repository

Powershell sites
http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx
http://www.powershell.org
http://powershell.com/cs/
http://www.powershellmagazine.com
http://www.powershellpro.com
http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx

2012/09/19

I'm Going to PowerShellSummit !!! @pshsummit

Seattle here I come !!!
I cannot wait to meet all my fellow PowerShell enthousiasts !

The PowerShell Summit will be held at Microsoft in Redmond April 22-24, 2013. Check here for details.





PowerShell Module included in System Center Configuration Manager 2012 SP1 BETA

Source

Microsoft just released the Service Pack 1 for System Center Configuration Manager 2012.
AND!! FINALLY comes with its own PowerShell Module !!! Woot Woot :-) 

Once the SP1 installed, all you need is PowerShell 3.0.
Already included in Windows Server 2012 or can be installed on Windows Server 2008


IMPORT THE MODULE

Import-Module "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"


CMDLETS

Add-CMBoundaryToGroup
Add-CMDeviceAffinityToUser
Add-CMDeviceCollectionDirectMembershipRule
Add-CMDeviceCollectionExcludeMembershipRule
Add-CMDeviceCollectionIncludeMembershipRule
Add-CMDeviceCollectionQueryMembershipRule
Add-CMDeviceCollectionToDistributionPointGroup
Add-CMDistributionPointToGroup
Add-CMSoftwareUpdateToGroup
Add-CMUserAffinityToDevice
Add-CMUserCollectionDirectMembershipRule
Add-CMUserCollectionExcludeMembershipRule
Add-CMUserCollectionIncludeMembershipRule
Add-CMUserCollectionQueryMembershipRule
Add-CMUserCollectionToDistributionPointGroup
Approve-CMApprovalRequest
Approve-CMDevice
Approve-CMUserDeviceAffinityRequest
Block-CMCertificate

2012/08/24

Introduction to CIM Cmdlets

Great article from the Powershell team blog:

Introduction to CIM Cmdlets

PowerShell 3.0 shipping with Windows server 2012 and Windows 8 brings a new set of Cmdlets to manage any server or device that complies with CIM and WS-Man standards defined by DMTF. In this blog post we will explore these new Cmdlets and how can they help IT Pros in managing a datacenter.
The list of new Cmdlets is given in the table below:
Cmdlet Purpose
Get-CimInstance Gets instances of a class.
New-CimInstance Creates a new instance of a class.
Remove-CimInstance Removes one of more instances of a class.
Set-CimInstance Modifies one or more instances of a class.
Get-CimAssociatedInstance Gets all the associated instances for a particular instance.
Invoke-CimMethod Invokes instance or static method of a class.
Get-CimClass Gets class schema of a CIM class.
Register-CimIndicationEvent Helps subscribe to events.
New-CimSession Creates a CIM Session with local or a remote machine
Get-CimSession Gets a list of CIM Sessions that have been made.
Remove-CimSession Removes CimSessions that are there on a machine.
New-CimSessionOption Creates a set of options that can be used while creating a CIM session.

Basic terminology

If you are already familiar with terms like WMI, CIM, WinRM and WS-Man, you can skip this section.
CIM: Common Information Model (CIM) is the DMTF standard [DSP0004] for describing the structure and behavior of managed resources such as storage, network, or software components.
WMI: Windows Management Instrumentation (WMI) is a CIM server that implements the CIM standard on Windows.
WS-Man: WS-Management (WS-Man) protocol is a SOAP-based, firewall-friendly protocol for management clients to communicate with CIM servers.
WinRM: Windows Remote Management (WinRM) is the Microsoft implementation of the WS-Man protocol on Windows.

Introduction to CIM Cmdlets

2012/06/14

LazyWinAdmin v0.4 released

UPDATE 2016/04/26: Lazywinadmin is now open source, see here: https://github.com/lazywinadmin/LazyWinAdmin_GUI

LazyWinAdmin is a PowerShell Script that generates a GUI/WinForms loaded with a tons of tools

The Form was created using Sapien Powershell Studio 2012.


2012/06/01

LazyWinAdmin v0.4 - Sneak Peek

Sneak peek : LazyWinAdmin v0.4

LazyWinAdmin is a PowerShell Script
This script generate a GUI/WinForm that was created using Sapien Powershell Studio.

I've been working in LWA for a while now.
This project of mine is mostly to help myself in my day to day Windows System Administrator tasks.

The goal of this tool is to centralize a lot of commands I use everyday inside a GUI and waist less time doing some tasks...
It also taking advantage of a couple of other tools Built-in in Windows: Computer Manager, Services.msc,...
And some non-built-in: Psexec, ADExplorer, SYDI-Server.vbs etc...


"General" tab contain my Top Used tools.


The "Check" button allow you to check the following connectivity item:
Ping (test-connection), Permission (test-path \\Computer\c$), RDP (Test of the port 3389), PsRemoting (PowerShell Remoting Enabled), OS (WMI), Uptime (WMI)





Autocomplete of the ComputerName. 
The script run a Get-Content on a Computers.txt when the form is loading.