PowerShell and CSV

Just collect a few articles about reading CSV with PowerShell.

  1. Read a Csv file with powershell and capture corresponding data
  2. Powershell read from CSV set variables
  3. Use a CSV File to Populate Parameters of PowerShell Cmdlets

This one is more practical relate to AD account creation.

Use PowerShell to Read a CSV file and Create Active Directory User Accounts

Advertisements

Make a SharePoint site searchable or not searchable

Here are the steps to make a SharePoint site searchable in general:

https://support.office.com/en-us/article/Enable-content-to-be-searchable-d7ba92db-8618-43fe-87ee-adf03d973062

A simple PowerShell script that makes a SharePoint site not searchable:

https://sharepoint.stackexchange.com/questions/36717/powershell-or-script-to-make-all-lists-and-libraries-unsearchable

and a more complete PowerShell script:

https://gallery.technet.microsoft.com/office/How-to-configure-a-6820f0d5

 

PowerShell for Azure Active Directory (AAD) and Office 365

Well, this is just some notes on how to prepare PowerShell to manage Azure Active Directory and Office 365. But similar to connecting to AD in Azure, you also need to go through these steps to connect PowerShell to an Azure subscription.

This is quite interesting actually when I put them together. As AAD still has two active environment versions, same as Azure console – Classic and RM – they belong to different logins, a little confusing to admins. Also PowerShell modules need to be installed and updated to enable different cmdlets set in order to manage different products – cloud, non-cloud, 3rd-parties like AWS, etc. So when something is not working, maybe you are in a wrong dimension or Microsoft wants you to update the binary you are using.

Azure Subscription AAD Module v1 (MSOnline)
– General Availability version
– Public Preview version
AzureAD v2
– General Availability version
– Public Preview version
Pre-requisites:
– Install lastest Azure Tools using Web Platform Installer
> Add-AzureAccount
> Get-AzurePublishSettingsFile
image
> Import-AzurePublishSettingsFile
> Select-AzureSubscription
Pre-requisites:
MS Online Services Sign-in Assistant
Windows AAD Module for Windows PowerShell
Pre-requisites:
PowerShellGet
image
Step 1: Install Azure PowerShell
Install-Module AzureRM
Download and install Azure AD Connect (.msi)
Update AAD Module > 1.0.8070.2
Download from PS Gallery
Install AAD Module
Update AAD Module
Step 2: Connect to an Azure account
Login-AzureRmAccount
Connect to Azure AD

$Msolcred = Get-credential
Connect-MsolService -Credential $MsolCred

Connect to AAD

$AzureAdCred = Get-Credential
Connect-AzureAD -Credential $AzureAdCred

Step 3: Run Azure PowerShell cmdlets

v1 cmdlets are here v2 are here
More information: PowerShell Gallery Office 365 PowerShell

One more thing: remember to check the update time of anything posted online, those older than 3 months might be useless.

How to enable telnet client using PowerShell

Telnet is a quite useful connecitivity verification tool, especially during the system set up or troubleshooting. For some reason, mostly security concern, this feature is disabled since Windows Server 2008. But when you want a quick check, it’s really a pain to open the Server Manager and click, click, click… Fortunately we have PowerShell. So here is the one-line command to turn it on:

Add-WindowsFeature telnet-client

And another command to turn it off, before you log-off:

Remove-WindowsFeature telnet-client

Very cool!