A simple powershell function

Today, I’d like to share a very simple function I wrote some years ago, I would even say many years :). This is a simple powershell function, without any error handling and parameters checking. I needed at some point to have proper logging of my scripts and I wanted to have it displayed on screen and logged to the file as well for some later usage. I wrote this function to achieve my need.

Continue reading

Powershell : A simple use of DSC

I’m a great PowerShell fan, I think it’s the second best (or maybe first one) thing Microsoft bring to IT world – for me still the one and best is MS Exchange.
Some time ago MS introduced a thing called Desired State Configuration, as I’m correct it was with PS 3.0, for sure with PS 4.0.
You can read a lot of DSC just to google it or go to MS site. I won’t explain how DSC works and what is the pull server, how to enforce configuration compliance, etc …

For my compliance I’m using SCCM, however I found Powershell DSC really useful for my initial server configuration, so I’d like to share how easy and handy is to build some initial server configurations – “Make it smart, make it simpe” – from this starting point one can go wherever … sky is the limit šŸ™‚ Continue reading

Case Study : Windows 2012 R2 – ping internally returns wrong IP on multihomed server

As system engineer I’m providing a 3rd level support in IT areas I work on. So one day a strange case came to me.Ā  An issue was reported that on multi-homed Windows 2012 R2 server – this case was : 2 network interfaces on Windows 2012 R2 (I can imagine it can happen on 2+ network interfaces Windows 2008 or newer). So on mutlihomed Windows Server 2012 R2, when try to ping internally FQDN wrong IP is returned. Continue reading

How to downlaod files from the web (through proxy) using powershell

Today I had to download around 900 files from ftp server, however firewall was blocking almost everything, however I was able to access the FTP server via web browser (I used one and only IE :)). So a colleague advised me to use wget to download the files, but I’m a kind of MS guy and I’m not get used to using wget, so I decided to use powershell. So I’d like to present you how easy it is to download the files using powershell (I’m Ā using v.2). Continue reading

Script generating report for DAG replication queues and status on Exchange 2010

When I was working as mail engineer I had to write the script for monitoring CCR queues on Exchange 2007, then my friend had rewritten the script to monitor DAG replication queues on Exchange 2010. So what script does, it generates a html report about the DAG replication queues and sends it via email to defined recipients. There were some tricky parts we’ve had to face, for example there was no possibility to use any open-relay receive connector to send mail, so solution was to create an “eml” file and put it to Exchange “Pickup” folder and it’s a bit tricky to create eml file containing html attachment :). Continue reading

HOWTO : Create gMSA user account

In last post I wrote few words about MSA and gMSA and in this post I’d like to show you how to make use of gMSA using Powershell of course :).

My test environment is

DS-DC-01 – Windows Server 2012 domain controller
SC-DB-01 – Windows Server 2012 machineĀ for SCCM SQL database
SC-DB-02 – Windows Server 2012Ā for extending SQL to a cluster.

Continue reading

HOWTO : Creating new Active Directory forest with Powershell

I’ve seen many howtos, manuals how to install Active Directory domain, but they were always GUIĀ based, as example I’ll put just 2 links, one is TechnetĀ and second is Petri website. So in this post I’d like to present how to install and configure basic AD forest using Powershell, it requires just a few input data and 2 powershell commands.

Continue reading

Get-ADUser : A referral was returned from the server

Recently a friend of mine had to query for the users and user properties who are members of “Enterprise Admins” Active Directory group. Of course you need to import ActiveDirectory powershell module to run it. The command is pretty simple

So command should prepare a csv file with all the users and their properties, even if users are members of nested groups. However a strange error we’ve received.
Continue reading

Getting information about storage in VMWare script

Probably many people had to face such task before me. I had to get information about storage paths in VMWare including the ESX cluster name, hostname, HBA, etc.
I could of course look for a script which was already written, but probably in the same time I was able to write my own script, which was more challanging for me. I’m using PowerCLI cmdlets, so I need at least VMware.VimAutomation.Core pssnapin. So here goes the script. Continue reading

Powershell, not only Microsoft …

PowerCLII reckon, that Powershell is one of the best Mictosoft products. It came alive when Vista/Windows Server 2008 (codename Longhorn – who remembers this šŸ™‚ ) were released. I’m great Powershell fan, it allows to manage many Microsoft products, but not only. Once, I had to change few options in VMWare environment: “Memory/CPU Hotplug” and “Check and upgrade Tools during power cycling” as on screen below

I could do that manually, but changing manually settings in over 5 virtual machines is simply waste of time.Ā  Continue reading