Scripting

Have you ever wondered how to get FQDN of local or remote computer(Workstations/Server) using powershell? There are some methods available over internet but they are not really upto the mark. All they do is, pick computer name and domain name from two places and concatenate them to form a FQDN. But as a System administrator [...]

{ 0 comments }

Would it not be helpful if all scripts are at one place and you can navigate/browse them through single window? Microsoft team is working on a tool called Script Explorer for Windows Powershell. Go through below link for more details. http://blogs.technet.com/b/exchange/archive/2012/03/14/check-out-microsoft-script-explorer-for-windows-powershell-pre-release.aspx

{ 1 comment }

“Did you mean windows powers hell ?” is message you get when you search for “Windows PowerShell” in download.microsoft.com. Isn’t this funny? One of my friends noticed this. I feel MS should look at their search algorithm and make PowerShell as known word and don’t recommend “Powers hell”. If any MVPs or Microsoft Persons happens [...]

{ 0 comments }

We want to assign output of a cmdlet/function to a variable so that we can use it in further processing. In scripts it is very inconvenient to debug a issue if the output is going to a variable and not to console. In such cases we can do nothing other than printing the variable value [...]

{ 1 comment }

The popularity of PowerShell is increasing day-to-day and now every System administrator want to say bye to their VB scripts and enter the powerful powershell world. A system administrator who is familiar with VB script(or has in home grown scripts in VB) want to try powershell, the first question he gets into mind is, “how [...]

{ 0 comments }

This powershell function helps you to get the network status of all network adapters in a given computer. Using this script it is easy to determine the status of all network connections in remote computer to see whether it is connected/disconnected/media disconnected/and different other statuses. This script queries Win32_NetworkAdapter WMI class for list of network [...]

{ 2 comments }

In this post, I will show you how to pragmatically query battery status in laptops using powershell. It is important to check batter status before performing some critical tasks like patch updates or service pack updates via some automation(s). If the laptop charging drains down in middle of the upgrade, it can corrupt the operating [...]

{ 3 comments }

I wrote on the similar topic before. My earlier attempt was to determine OS architecture but this time, I am going to talk about querying CPU architecture using powershell code. It is needless to explain the difference between these two things. So, below is the code which helps you determine CPU architecture of a computer. function [...]

{ 4 comments }

  This small powershell command helps you to get the domain controller name currently in use. PS C:> ([ADSI]“LDAP://RootDSE”).dnshostname DC1.Techibee.com PS C:> You can also know to which site this DC belongs to. PS C:> ([ADSI]“LDAP://RootDSE”).servername.tostring().split(“,”)[2].Split(“=”)[ 1] SITE1 PS C:> Isn’t it looking a bit complex to query the site name? Any alternatives? Yes, we [...]

{ 0 comments }

One other nice thing I found with PowerShell is it’s ability of using APIs by importing DLLs. Below is one example, where user32.dll is imported and LockWorkstation Function is invoked to lock the desktop. Btw, I grabbed this script from TechNet Library Function Lock-WorkStation { $signature = @” [DllImport("user32.dll", SetLastError = true)] public static extern bool [...]

{ 0 comments }