martes, 22 de marzo de 2016

Powershell Web Access

Windows Powershell Web Access


I was thinking about how to connect into a Powershell console from a Mac or Linux computer, or just remotely from any public computer avoiding to do Remote Desktop.

One of the options is SSH (Secure SHell) for Powershell, to be honest I didn't test it yet but I am excited about to do it.

Another option is something call Windows Powershell Web Access.

So, I will be able to connect into a Powershell console from any computer that has a Web browser supporting Java Script.

Configuring Windows Powershell Web Access

  1. First of all we need to add the feature Powershell Web Access running the following command:
  2. PS:\>Install-WindowsFeature -Name WindowsPowershellWebAccess
    
    
  3. Ok, now we need to configure the Powersherll Web Access running the following command:

    PS:\>Install-PswaWebApplication -UseTestCertificate -WebApplicationName WebPS
    

    -UseTestCertificate: creates a certificate for testing enviroments.
    If you want to configure a production environment you should use a certificate signed by a CA.

    -WebApplicationName:The name of the ends of the website, in the example above is https://<ServerName>/WebPS 


















    More about Install-PswaWebApplication command here.
  4. After Windows PowerShell Web Access is installed and the gateway is configured, users can open the sign-in page in a browser, but they cannot sign in until the Windows PowerShell Web Access administrator grants users access explicitly.

    In the following command I'm providing access to all the users from any computer. 
  5. PS:\>Add-PswaAuthorizationRule –UserName * -ComputerName * -ConfigurationName *
    








  6. Then we need to browse our server following the link of our Powershell Web Access, by default is https://<ServerName>/pswa/
    Also, as we had showed above, you can specify your own Powershell Web Application name.

    Then, we need to login using any kind of user credentials with access to the server.
    And in Computer name: we need to write the server that we want to connect to.

  7. Enjoy powershell form the web!

miércoles, 2 de marzo de 2016

Remote Powershell to manage Office 365

Yhea, in the previous post I wrote about connecting to Office 365 using powershell in order to do taks related to Office 365.


But if we want to go a bit deep and do some Exchange tasks (For instance Get-Mailbox), we will need to connect into our  Exchange Online, if not we’ll get an error like:



So, in order to connect into our Exchange Online and be able to break everything … sorry, I mean to FIX everything, we should follow the next steps:


1- Update the default PowerShell Execution Policy

Set-ExecutionPolicy Unrestricted


2- Creating a Remote Session to Exchange Online. 
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession

NOTE: After that a window will pop up asking you for your credentials. You should enter your Office 365 admin user.

3- Done, you are connected to your Exchange Online. 
In order to check your connectivity, now you can run the command Get-Mailbox  

lunes, 29 de febrero de 2016

Get Office 365 users using Powershell

Sometimes, at work I need to check the licensed users in Office 365, I can check them from the Office 365 Admin website, but I’m not sure if I’m able to export them to an Excel (Or CSV file).

So, in order to do that I’ll do it using our little friend, the uncle PowerShell.

Before jumping into the commands, you will need to install some modules to connect to your Azure Office 365 platform.

  1. First install the  Microsoft Online Services Sign-In Assistant for IT Professionals RTW
  2. Then Azure Active Directory Module for Windows PowerShell (64-bit version) 
Now, open a powershell terminal and type:
 
PS C:\WINDOWS\system32> Connect-MsolService
A new window will pop up, enter your Office 365 credentials there. And then, if you don't have any error, you will be in. Now type the following command:
PS C:\WINDOWS\system32> Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | Export-Csv C:\LicensedUsersOffice365.csv


And that is it, you will have an excel file of all your licensed users on Office 365.

sábado, 18 de julio de 2015

Power Shell - Export Active Directory Users

Why I need to export my Active Directory users/accounts ?

Working as a System Administrator sometimes (actually always) is a bit messy organise the users and accounts that you have in the Active Directory.
Sometimes do you have old users than left the company years ago, or maybe you created twice, or three times the same Service account.

However, it's a good practice to have a list of all your users in an Excel document, to take some actions about the organisation/administration of your Active Directory.

Here is a Power Shell script to export all your users to a CSV file, after that you will be able to apply filters and look for users, accounts that you don't need anymore.

The Script


 

#Path to export the CSV file, the folder must to be created before.
$path = Split-Path -Parent "C:\Export_AD_Users_to_CSV\*.*"

#Variable for the date.
$LogDate = get-date -f yyyyMMddhhmm

#Define CSV and log file location variables
#they have to be on the same location as the script
$csvFile = $path + "\ALLADUsers_$LogDate.csv"

#Import the AD Module
Import-Module ActiveDirectory

#Set the OU to do the base search for all user accounts.
$SearchBase = "OU=Domain Controllers,DC=contoso,DC=com"

#Get Admin account credential.
$GetAdminact = Get-Credential

#Define variable for a server with AD web services installed.
$ADServer = 'Server01'

#Define "Account Status" 
$AllADUsers = Get-ADUser -server $ADServer `
-Credential $GetAdminact -SearchBase $SearchBase `
-Filter * -Properties * | Where-Object {$_.info -NE 'Migrated'}

#Select the properties that you want to export.
$AllADUsers | 
Select-Object @{Label = "First Name";Expression = {$_.GivenName}},
@{Label = "Last Name";Expression = {$_.Surname}},
@{Label = "Display Name";Expression = {$_.DisplayName}},
@{Label = "Logon Name";Expression = {$_.sAMAccountName}},
@{Label = "Full address";Expression = {$_.StreetAddress}},
@{Label = "Job Title";Expression = {$_.Title}},
@{Label = "Directorate";Expression = {$_.Description}},
@{Label = "Department";Expression = {$_.Department}},
@{Label = "Phone";Expression = {$_.telephoneNumber}},
@{Label = "Email";Expression = {$_.Mail}},
@{Label = "Last LogOn Date";Expression = {$_.lastlogondate}} |

Export-Csv -Path $csvfile -NoTypeInformation

viernes, 19 de junio de 2015

Manage 2008 from Server Manager 2012

Introduction

Windows Server 2012 allows us manage server remotely from Server Manager.
Also, we could just use Remote 
Server Administration Tool (RSAT) from client computer (Windows 8 or Windows 10).

However, if we are using a Windows 10 client computer or a Server 2012, we will need to run some setup in the 2008 server.
This setup will be installing WinRM and doing some configuration to avoid this manageability warning of “Online – Verify WinRM 3.0 service is installed, running, and required firewall ports are open".

Warning

Solution


  1. Install Windows Management Framework 3.0
    Go and get the appropriate .msu from here: http://www.microsoft.com/en-us/download/details.aspx?id=34595
  2. Config WinRM
    From a Power Shell terminal, with elevated right, type "winrm quickconfig"

  3. Create Firewall Rule
    Allow port 5985

lunes, 15 de junio de 2015

Remote Desktop Connection Manager

Remote Desktop Connection Manager

One of the best free software tool from Microsoft to administrate and manage Windows Server.
It's free, easy to use and very intuitive.


Download Link:

NOTE: For the installation you must to have .NET Framework version 2.0  installed in your pc/server.

Here is a link to install the .NET Framework version 3.5 and 2.0 in Windows 8, 8.1, 10 :)
https://msdn.microsoft.com/en-us/library/hh506443(v=vs.110).aspx

Kind regards.

jueves, 11 de junio de 2015

Windows 10 - Configure Gmail Mail and Calendar

Windows 10 - How to configure my Gmail account with Windows Mail & Calendar

Introduction


One of the good features that Windows 10 has is that you can integrate it with your personal account.
For instance, you are able to configure the Windows Future Mail & Calendar app with your Gmail account.

Step by Step


In order to do that, you must to follow the next easy steps.


  1. First of all you need to open the Microsoft Mail or calendar to configure your Google account.
    (See Figure 1)
    As you see, the Microsoft account it was configured before, now we must to click on Add Account button to add the new on.

    Figure 1
  2. Then, we will need to choose which account we want to add, that could be any one of the listed in the Figure 2.
    Figure 2
  3. After selected the Google account, we will asked for the Google account credentials.
    (See Figure 3)
    Figure 3
  4. We will be asked to confirm the connection with the Google account (Figure 4).
    Also, after that we will be asked if we want to save our password, I selected yes but this is up to you.

    Figure 3
  5. Now, we are ready to use our Google Mail and Calendar with the Windows 10 Mail & calendar Client.
    Windows 10 - Mail Client

    Windows 10 - Calendar Client

Conclusion

Windows 10 has a lot of new features, I think that it's much superior than Windows 8.1.
It's a perfect mix between Win 8.1 and  Win 7.
The Mail and Calendar clients has a good look and feel, it works very well and also you can configure it to synchronize every hour/ every 10 min/ all the time, etc.

Let's go to see which more has Microsoft to surprise us.