Thursday, 21 April 2016

PowerShell command to export a list of domain users from AD group to a CSV file

Here I go with another post on PowerShell. This time, I would like to share a PowerShell command that will help you to export list of users of particular AD (Active Directory) group to a CSV file.
Run PowerShell and type following commands:

# This will import ActiveDirectory module
Import-Module ActiveDirectory

# This command will export list of users from GroupName to a CSV file
Get-ADGroupMember -Identity "GroupName" -server "TestDomain" -recursive | get-aduser -Properties mail |select name,samaccountname |export-csv -path c:\Script\report.csv -NoTypeInformation

In above command, replace GroupName with the Group you want to retrieve members list. Type your domain name in place of TestDomain. Once you run above command, it will create a CSV file “Report.CSV” and save it in C:\Script folder.

I hope you find this post very useful.

Disclaimer: www.TechieTalks.co.uk does not conceal the possibility of error and shortcomings due to human or technical factors. www.TechieTalks.co.uk does not bear responsibility upon any loss or damage arising from conduct or activities related to the use of data and information contained in this blog.

Tuesday, 12 April 2016

PowerShell Script: Find out free disk space from multiple servers

Hi All, this is my very first post on PowerShell Script. Today, I am going to share a script that you can use to find out free disk space from multiple servers. You will have to create a Text file and a PowerShell script to accomplish this.

Let’s begin by creating a Text file. I have setup a folder on my C: Drive called PS_Script (C:\ PS_Script). I created a Text file, ServerNames.txt, and saved it in C:\PS_Script folder.



Use following code to create a PowerShell script and save it as DiskReport.PS1.

#Get Current date
$currdate = (Get-Date).tostring("dd-MM-yyyy")

#Set path for output file
$report = "C:\PS_Script\" + "DiskSpaceReport_" + "$Currdate.html"

#Run command to get free disk space from multiple servers and export output to HTML file
Get-WmiObject Win32_LogicalDisk -filter "DriveType=3" -computer (Get-Content C:\PS_Script\ServerNames.txt) | Select SystemName,DeviceID,VolumeName,@{Name="Size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="FreeSpace(GB)";Expression={"{0:N1}" -f($_.freespace/1gb)}} | ConvertTo-HTMl | Out-File $report

When you run above PowerShell script, it will create a HTML file in C:\PS_Script folder.  Please make sure that you are running the PowerShell script using your admin account.

I hope you like this script.

Disclaimer: www.TechieTalks.co.uk does not conceal the possibility of error and shortcomings due to human or technical factors. www.TechieTalks.co.uk does not bear responsibility upon any loss or damage arising from conduct or activities related to the use of data and information contained in this blog.

Tuesday, 5 April 2016

Changing password while using Remote Desktop Connection

Hi All, I know it’s been a long a time since I have written an article. Today I came across a question where user wanted to change his/her password while they are connected to a Server remotely via Microsoft Remote Desktop Connection.

Generally, you press CTRL+ALT+Del , you get  the following choices that includes Change a password… option.


This works perfectly fine if you are logged in locally and wants to change password. But if you are logged on to PC remotely using Remote Desktop  connection and press CTRL+ALT+DEL from keyboard, it will apply command to your local PC instead of remote PC.

There are two ways to change password using Remote Desktop connections.
  •     Press CTRL+ALT+ END from your keyboard while you are logged in to Remote PC. You should get following options:
  •     Alternatively, press Win +R key in your Remote desktop connection. Type OSK to launch OnScreen Keyboard. Press CTL+ALT from your keyboard and use mouse pointer to click on DEL button on OnScreen Keyboard. This will bring up the same options shown in above image.
I hope you may find this post very useful.

Disclaimer: www.TechieTalks.co.uk does not conceal the possibility of error and shortcomings due to human or technical factors. www.TechieTalks.co.uk does not bear responsibility upon any loss or damage arising from conduct or activities related to the use of data and information contained in this blog.