30 basic Powershell commands to start with Windows Server

Getting started with Windows 2019 nano server can be very challenging especially if you are not used to CLI on Linux servers. I decided to install Windows 2019 server core only i.e; without GUI and take it as a challenge to learn more about it. Since I’m mostly from a Unix/Linux background, I decided to dive a little bit more in the Windows Operating system. In this article, I’m sharing some commands to start with. However, the Microsoft website covers enough part which will lead to the Windows 2016 MCSE certification. My goal in this article is to get PowerShell beginners on track and paint an idea of what Windows Powershell is capable of.

Windows Updates

1. Some modules are not available by default on the PowerShell. So you will need to manually download it. I downloaded the module PSWindowsUpdate which will enable me to update the OS from PowerShell.

Get-Module PSWindowsUpdate

2. One of the first things you might want to do is to get the updates that need to be installed on  the Operating System first which I did with the following command:

Get-WindowsUpdate

3. Now you can install the updates using the following command. Once installed, reboot the server which might take some time.

Install-WindowsUpdate

4. You can also find the list of updates installed on the machine using the following command:

Get-Hotfix

OS basic verification

5. To get the version of the PowerShell, use the following command:

  • Get-host | select Version
  • $PSVersionTable

6. To get the reboot history :

Get-EventLog system | where-object {$_.eventid -eq 6006} | select -last 10

7. List of services running:

Get-Service

8. List of Installed programs:

Get-Module PSWindowsUpdate
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize

9. Get the process running on Windows

Get-process

Networking

10. Finding the rules on the firewall:

Get-NetFirewallRule

11. IP configuration:

Get-NetIPConfiguration

12. To verify if IPv4 or IPv6 is enabled or not

Get-NetAdapterLso

13. To get the routing table

Get-NetRoute

14. Source and remote IPs on listening mode

Get-NetTCPConnection | ? {$_.State -eq "Listen"}

Storage

15. Get the disk space information

Get-WmiObject win32_logicaldisk
Get-PhysicalDisk

16. To get the health status of the disk:

Get-PhysicalDisk | Sort Size | FT FriendlyName, Size, MediaType, SpindleSpeed, HealthStatus, OperationalStatus -AutoSize

17. Getting the used/free space:

Get-PSDrive C | Select-Object Used, Free

PowerShell Modules and repository

18. The PowerShell Gallery is the central repository for PowerShell content. You can find new PowerShell commands or Desired State Configuration (DSC) resources in the Gallery. To check which repository you are using use the following :

get-PSRepository

19. By default, PowerShell modules are installed in several directories. You can download certain modules in any directory you want. To execute it, you need to append the environment. To see the module paths of your environment, launch the following command:

$Env:PSModulePath

20. To add a path to the environment’s module path, use the following command:

$env:PSModulePath = $env:PSModulePath + ";C:\ModulePath"

21. To get a list of installed modules and the directories in which it has been installed:

Get-Module -ListAvailable

22. To install a module, you can search for it and install it directly:

find-module -Name PendingReboot | install-module 

23. After installing a module, it is always a good practice to import it using the following:

Import-Module PendingReboot

24. To get information which command to use for a pending reboot use:

Get-Command -Module PendingReboot

Downloads and unzip

25. Recently, I saw a link where having a script on Technet. You can use the following command to download the zip file.

Invoke-WebRequest https://gallery.technet.microsoft.com/scriptcenter/Get-RebootHistory-bc804819/file/130620/2/Get-RebootHistory.zip -outfile Get-RebootHistory.zip

26. To unzip a file:

Expand-Archive -path '.\Get-RebootHistory.zip' -DestinationPath 'C:\Users\Administrator\Documents\WindowsPowerShell\Modules'

Getting Help

27. Getting help with commands arguments are pretty easy. Let’s say you want to know the possible arguments of the command Get-Command, simply do:

Get-Command -?

28.  You can also use the Get-Help module. For example, consider the Compress-Archive module:

Get-Help -name Compress-Archive

29. Consider that you need an example of a specific module:

Get-Help -name Compress-Archive -examples

30. The help/man command is also interesting to get fast syntax about a command.

man Compress-Archive
help Compress-Archive

One interesting source of information is gallery.technet.microsoft.com/scriptcenter where you can access several scripts for Microsoft Windows Server Administration. Personally, Windows PowerShell commands seem to be more complexed compared to Linux commands. Probably, its a matter of getting used to it. I will try my best to update this article. Don’t forget to comment below if needed. My last article on Windows was on the installation of SSH on Windows server through Powershell.


My trip to Pension Cargo, Bras-Panon – Reunion Island

I had a splendid time in Reunion Island this week. I stayed at “Pension Cargo” which is owned by Christian, a friend at Bras-Panon, Reunion island in the north-east of the neighbor island thirty minutes away from Roland-Garros, St-Denis Airport. I reached there on Wednesday at around midnight. Christian was waiting for me as I told him that I will reach there by Taxi. I was so tired already and went to sleep.

On the next day, I went for a casual meeting on cybersecurity at a Media-Tech center as well as meeting with another acquaintance who is in the medical field. At St-Marie Media-Tech center, I got the opportunity to discuss Ansible, Automation technologies, Linux and TLS 1.3 for the IETF hackathons by the cyberstorm.mu team. It’s true that in Mauritius there is considerable effort to be made to do better Developers conferences, but, I seized this opportunity to build up the circle on the neighbor island which is also advanced in software development and Automation Engineering. The day was an enriching and successful one, however, time-consuming it was, I have been able to achieve my goal. I reached quite late at “Pension Cargo” and was so tired.

Pension Cargo
Pension Cargo

On Friday, I went for a nature walk near Pension Cargo. That place is still in its natural state with lots of exotic fruits.

Exotic fruits on the beach near Pension Cargo
Exotic fruits on the beach near Pension Cargo

In case you are a fan of the nature walk, I’m sure you would like it. It was indeed a nice time meeting up with several Linux user groups to discuss avenues of collaboration between Reunion and Mauritius. However, there are much more to see in Reunion island.

Random picture taken near Pension Cargo

IMG_2608
IMG_2608
IMG_2606
IMG_2591
IMG_2591
IMG_2591
IMG_2591
pensioncargo
IMG_2607
IMG_2607
IMG_2568
IMG_2568
IMG_2568
IMG_2568
IMG_2568
IMG_2568
IMG_2594
IMG_2596
IMG_2596
IMG_2596
IMG_2593
IMG_2566
IMG_2584
IMG_2573
IMG_2573
IMG_2573
IMG_2592
IMG_2592
IMG_2592
IMG_2606
IMG_2606
IMG_2606
IMG_2606
IMG_2607
IMG_2607
IMG_2567
Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...

At “Pension Cargo”, you can never miss the Reunion beer made locally. I got it free too! This is something to never miss at all!

Beer made locally in Reunion island
Beer made locally in Reunion island

As regards to breakfast, lunch and dinner, its always nice and yummy whether it is chicken, duck, and seafood which is always accompanied by salads french style-made.

Lunch with chicken, Seafood, Potatoes and Salads
Lunch with chicken, Seafood, Potatoes, and Salads

In case, you are heading up to Reunion island or in transit, feel free to check out “Pension Cargo” which is always worth the price. As usual, I convinced Christian to join and create a Twitter account as a marketing strategy which worth for where it is located. Pension Cargo can seem to be easily booked on Booking.com and Airbnb. However, you can always contact the Christian and his family who are always there to welcome you with a smile and lots of beers and goodies.

The team at the bar
The team at the bar

I got the opportunity to visit Riviere des Roches which is located a few meters from where I live. I was told that fishermen build up walls on the river with the aim to narrow the passage and by using fishing nets to catch “bisik” fish known as the caviar of the Reunion island which is pretty expensive and delicious. Unfortunately, this can be a problem to the ecology of the island as depending on the curve being built with the wall and the increase of sea water levels might change drastically the width of the river. This is contributing to severe land erosion and inviting sharks close to the river. Obviously, some people in the vicinity are not happy at all. Its all a question of eating the famous caviar of Reunion island!

Walls built on the river
Walls built on the river

Walls built on the river to catch fish

IMG_2620
IMG_2621
IMG_2621
Loading image...Loading image...Loading image...

On the way to Mauritius, the weather was sunny and I seized the opportunity to make a video for my YouTube Channel. I already had so many landings from several countries. Why not add Mauritius to the playlist?


Installing the Networker Management Console (NMC) on CentOS 7

In the last article, we have seen how to install Dell EMC Networker on CentOS7. There have been some issues with dependencies. In this article, I will install the Networker Management Console on the same server. Prior before installing, we will see the services running when the networker services have been started. Then, I will compare if after installation of the NMC.

Before proceeding to installation, the packages that I will install is :

lgtonmc (Networker Management Console) – Gives you the ability to access the Management Interface or Management console to manage backups.

1. The services running before the installation is as indicated in the screenshot below:

2. In the previous article, I downloaded all the packages. From the directory, I have installed the NMC using the RPM command followed with the execution of the script /opt/lgtonmc/bin/nmc_config. You will be prompted to answer a few questions for the installation. I selected the default answer except to the creation of user for the PostgreSQL database.

3. Now, we can see a bunch of new services is running such as more Java processes and PostgreSQL.

4. Since we installed the NMC on the VM, we should be able to access the console on the same network on the port 9000. My VM is actually configured with the IPAddress 192.168.100.19 and by accessing it on port 9000 will now show me the console.

5. As you can notice on the screenshot above I don’t have Java Runtime enabled on the Mac. So I had to install and enable it. Follow the instructions for the installation by clicking on “Browser, OS, & JRE Requirements”.

6. Once installed and activated, you should be able to access the console by clicking on “Click here to start Management Console”. The prompt to enter username/password should then appear.

The default username is Administrator and password is the one you have set when installing Networker.

7. Follow the instructions to set up the database backup server, authentication server etc.. and at the end, you should be able to reach the console.


Installing EMC Dell Networker 9 on CentOS 7

Its been since some days, I attended a training on EMC Dell Networker 9 in Mauritius itself. Though not everything can be covered in the training such as the installation of the networker on Linux machines, I decided to install it myself on my lab.

photo credits: dell.com

For those who are not familiar with Networker 9 formerly called Legato NetWorker is an “enterprise-level data protection software product that unifies and automates backup to tape, disk-based, and flash-based storage media across physical and virtual environments for granular and disaster recovery.”. To install it, I created a Centos 7 minimal installation lab on virtual box, made an update and install some few packages such as vim, tcpdump, net-tools, traceroute, epel-repo, locate, atop, htop and wget. These are basic packages for my own use on the VM. It has nothing to do with the Networker installation.

To be able to download the necessary packages, it’s a prerequisite to register on the EMC Dell website first. Once authenticated, you can move on to the download section of the packages. Dell will provide you in a tar.gz all packages for Debian and RHEL as well. Even Avamar packages will be found there. So, you will need to install only the necessary packages. Follow the instructions below after registration on the Dell website and download of the packages and the links highlighted. Once the file has been downloaded and decompressed, you will notice several RPMs and DEBs inside. The one which will be needed for the networker installation are as follows:

  • lgtoclnt (Networker client) – Provides you the ability to perform file system backup and recovery options.

  • lgtoxtdclnt (Networker Extended client) – Provides additional feature support for NetWorker clients, such as snapshot backup support, command line utility support including server reporting and administration, cloning and staging support, and so on.

  • lgtonode (Networker Storage Node) – Provides features for the storage node which will control storage devices such as tape drives, disk devices, autochangers, and silos.

  • lgtoserv (Networker Server) – Provides you the web server of the Networker portal.

  • lgtoauthc (Networker Authentication Service) – Authentication layer used for the backup purpose.

  • lgtoman (Networker Manual) – Its important for the manual. However, it’s not a prerequisite.

Whilst installing these packages, you will notice dependencies problems. See the “Tips” section below for more information. I had to install the Glibc 32-bit package as some of the networker packages might depend on them.

Here is an idea what error message { libc.so.6 is needed by lgtoclnt-9.1.1.7-1.x86_64 } you may have while performing the installation.

This can be confirmed by a yum whatprovides libc.so.6 which is found inside glibc.i686 package

1. At this point, to continue on with the installation I made the following steps:

yum install glibc-2.17-260.el7.i686
rpm -ivh lgtoclnt*.rpm lgtoxtdclnt*.rpm lgtonode*.rpm lgtoserv*.rpm lgtoauth*.rpm lgtoman*.rpm

2. If you are installing the package one by one, you will need to install lgtoauth first before installing lgtoserv. After installation of lgtoauth, it will prompt you to launch the following script:

/opt/nsr/authc-server/scripts/authc_configure.sh

3. It will prompt you where to specify where you have installed the Java Runtime. At the time, I’m writing this article, I’m using Java Runtime 8 from the oracle.com website. Use the following syntax to download it from wget.

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn-pub/java/jdk/8u202-b08/1961070e4c9b4e26a04e7f5a083f551e/jre-8u202-linux-x64.rpm"

4. Once, downloaded and installed, java -version should provide you the runtime environment.

5. Now, you can launch the script /opt/nsr/authc-server/scripts/authc_configure.sh anew and it will prompt you to enter the key store and administrator passwords.

6. Once the installation is complete, you can now run the /etc/init.d/networker daemon and check the process running.

Tips:

  • The problem is that the GLIBC2.0 symbol is not provided by the x86-64 Libc on CentOS, but it is provided by the 32-bit i686 package. There is no real dependency of the EMC NetWorker 9.1 package on the 32-bit library, but this is probably a false dependency RPM problem. So it is necessary to download the following 32-bit packages from the CentOS website and install them.

  • If you have installed the JAVA elsewhere, you will need to specify the path launch executing the script /opt/nsr/authc-server/scripts/authc_configure.sh

  • The installation logs are found at /opt/nsr/authc-server/logs/install.log.

  • For testing purpose, I deactivated firewalld and disable SELinux.


My participation at #Afrinic29 in Yasmine Hammamet, Tunisia

My participation at Afrinic-29 in Hammamet, Tunisia was productive and unique in itself. The event took place between 26-30 November 2018 at Diar Lemdina hotel. These are the days that will always be remembered. Situated in the north of Tunisia, Yasmine Hammamet was the place selected and it was close to the beach. I still can’t believe I was on the Mediterranean beach discussing about Internet-related topics such as DNS, DNSSEC and Policies development in Africa region.

Before departing, I seized the opportunity to make a video and posted in on my Tunnelix.com Facebook Page as well as on my Tunnelix Twitter account.

For some reasons, I had to travel to Hungary, then to Germany then to Tunisia. So I got the opportunity to spend a night in Munich on Transit. The hotel in Munich was pretty nice and cozy. On the next day, I flew to Tunisia. Once landed in Carthage in Tunisia, the atmosphere was pretty polluted, but as soon as I reached Yasmine Hammamet, things are different. It was a pretty beautiful and calm place.

My main objectives were to :

  • Focus on the DNSSEC hackathon carried out under the umbrella of cyberstorm.mu titled Operation KSK-ROLLOVER.
  • Sharing knowledge in the Africa region.
  • Allocation of IPv4 and IPv6 in Africa region.
  • Presenting DNS and DNSSEC.
  • DNS Flag day.
  • Security incidents on DNS.
  • Policy discussion development in Africa.

During the event, I got the opportunity to speak with Afrinic29 fellow, Souad Abidi who shared pretty good experience about the event.

Also met with some guys from Chad republic and we shared some Linux and network techniques. Besides, I met with several guys from the ATI Tunisia telecom and we discussed a lot about the event especially about Policy development. I’m glad to receive media coverage from the cyberstorm.mu team who supported me a lot as well as ICT.IO who published an article about the event.

Overall, the event was very productive. I seized the opportunity to congratulate Afrinic staffs during the open mike session. Indeed, they did a good job which demands extreme planning. During my speech on DNSSEC as Devops engineer at Orange Business Services, several issues were raised such as hackathon carried out by the cyberstorm.mu team and even prospective future hackathon concerning other DNS applications. I also attended few sessions on IPv6, Cert Africa and others. Also got the opportunity to meet with people who are very busy with Policy development in Africa as well as the father of Africa Internet, Nii Quaynor.

During my free time especially at night, I went to the NA3NA3A Karaoke Tunisian songs. It was pretty nice and unique. Took some videos and made some audio recording for the car whilst i’m driving.

You can also view my youtube playlist for Afrinic29 here and here

Several pictures also taken can be viewed here my Flicker Account:

Afrinic29