Thursday, December 22, 2016

Create FTP with Local User Isolation (in Powershell Script)

FTP with user isolation is a magic feature that microsoft introduced since IIS 7.5. It's similar to chroot in linux that each user is jailed in each his own directory ;P. Each user's directory is isolated from other users' directories, so that other users' cannot see each other's directory which is a good security option.
If you are looking for Graphical Method to setup FTP with user isolation in IIS console, there is my another blog post for that.
In this blog post, I will show you how you can script to automate this setup. It is quite a large script & I do not use IIS cmdlets that is available only in server Windows 8, Windows 10, Server 2012, Server2012R2 because IIS 7.5 which is available in Server 2008R2 do not have cmdlets to configure IIS specifically.. So, editing the IIS xml configuration is the way to go. If you are running the script on Server 2008R2, you need to install powershell 3.0 first (To install Powershell 3.0 on Server2008R2, you will need Server2008R2 SP1 with .Net framework 4.0 installed). I commented in the script before each sections so that powershell users can easily understand the code/logic. You can also create ftp administrator with -AdminIncluded option to browse the uploaded files in all directories. Also, don't forget to run the script from elevated powershell command. Script is also provided in this post.

Example usages are:
1) To setup FTP user isolation with FTP Administrator account. FTP Site name is "My-First-FTP" and Port is 21. User name list is created under c:\userlist.csv
Create_FTP_Local_User_Isolation.ps1 -FtpSiteName My-First-FTP -Port 21 -AdminIncluded -UserListCsv c:\userlist.csv

2) To setup FTP user isolation without FTP Administrator account with the default site name,port and SSL.
Create_FTP_Local_User_Isolation.ps1 -RequireSSL -UserListCsv c:\userlist.csv
I put some pictures for reference. I first run the script to create 4 ftp users. Then, I included Admin on the next run. See Fig-1.
Fig-1: Create FTP with user isolation

Create FTP with Local User Isolation (in GUI Method)

The magic of ftp with user isolation is that every users has his own directory and this user cannot see or browse other users' directories. In linux, it is similar to "chroot" option after the user has logged in. This feature came from since IIS 7.5 (server2008R2).
In this tutorial, we are going to create FTP with user isolation in Graphical Mode. If you are looking for automatic setup, then I wrote a powershell script for this work here.

Tuesday, December 13, 2016

Powershell: Monitor ICMP Ping with Timestamps for Logging

Ping is the most basic and the most oldest built-in tool, that every system/network administrator cannot live without when troubleshooting network connection at TCP/IP Layer-3. I sometimes had to make long time ping test for network latency issues. Test-Connection is introduced since powershell 2.0. But, I found some issues while doing test-connection to some remote hosts, that is unable to display output instantly on console for some servers. Morever, it's unable to display the timestamp when the server is pinging its destination. So, using the built-in ping.exe, I re-write some wrap-up to suite for logging purpose with the display of timestamp & write to file in the background, using .net call & Tee-Object.

Saturday, December 10, 2016

List ALL VMware SRM Protected VMs with their Protection Group Names

In your VMware Site-Recovery-Manager Environment, you may need to fetch the list of protected VMs and their associated protection group for documentation purpose. For this purpose, I created this one-liner command to fetch the necessary information with Name, Protection Group Name, Description, Replication Type & Datastore.