Yammer Native Mode Alignment Tool YML report, powershell export option

Regular Contributor

Hi Everyone.

Yammer Native Mode Step by step guide mentions that the report exports as YML.


In that article it mentions a GITHUB option for converting the YML to a csv for easy analysis.

But there is no link

I found the GITHUB repository here


BUT it requires Visual studio to be installed to get the github code, to then convert the YML to csv.

WHAT !! come on you guys, the people responsible for YAMMER in an organisation do not and will not have Visual studio installed. How was this even allowed to get this far. [ rant over ]


What you should be able to rely on is the ability of the YAMMER or digital work place admins in an organisation to be able to run a powershell script. They may not know how to write the script but their role forces them to use PowerShell.


So does anyone have a PowerShell script that converts the YML report document into some reasonably comprehensible CSV ???



4 Replies

@Dorje McKinnon 


The following script is what I've come up with. Use at your own risk.

My hope is that the Yammer Native Mode team take this work, and make it more robust, and thus better for digital workplace professionals who are NOT software developers.


Note I updated the script 8 Sept, with -join ';' for hashtable and list values so that the CSV was easier to read.



"Yammer Native Mode Alignment Tool" YML report, export to CSV script 

This script was written because the report exported by the "Yammer Native Mode Alignment Tool"
reference https://docs.microsoft.com/en-gb/yammer/configure-your-yammer-network/native-mode-step-by-step-guide#3-preparing-to-run-the-native-mode-alignment-tool
is exported in YAML format as a YML file.
Microsoft's solution for us normal users was to get the GIT hub code and use it to read the YML file
reference   https://github.com/microsoft/nmarc

But most people who would be responsible for YAMMER and making this move DO NOT nor will ever have Visual studio installed.
They may understand scripting enough to run a pre built script.
So I have tried to create a PowerShell script here which generates a reasonably useful CSV

Two files will be exported to your downloads folder
- yammerNativeMode-groups.csv
- yammerNativeMode-users.csv 

This script relies on the "powershell-yaml" module

Install-Module powershell-yaml

References used to build this script
	a fair amount of curse words 
Writen by Dorje McKinnon
6 and 7 and 8 Sept 2022


#first check you have the right powershell module installed to do the YAML conversion

if (Get-Module -ListAvailable -Name powershell-yaml) {
    Write-Host "Module exists"
	Import-Module powershell-yaml
else {
    Write-Host "Module does not exist, install and import for use"
	Install-Module powershell-yaml
	Import-Module powershell-yaml

$pathToSaveCSVto = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path

$yamFileOriginal = "C:\temp\m365_alignment_report.yml"

$yamFileOriginalText = [IO.File]::ReadLines($yamFileOriginal)

$yamFileOriginalTextFirstRow = $yamFileOriginalText | select-object -first 1

if($yamFileOriginalTextFirstRow -like "*This report was generated*") {
	#this file has two first lines containing --- which isn't OK in true YAML documents
	#So remove the first line from the document we're going to report on
		$yaml = [IO.File]::ReadLines($yamFileOriginal) | select-object -skip 1
	} else {
		#don't skip the first row 
		$yaml = [IO.File]::ReadLines($yamFileOriginal)

$yaml | select -first 3

#then replace firs colon on each of these, because standard YAML can't deal with it 
$yaml = $yaml.replace(':GROUPS:','GROUPS:')

$yaml = $yaml.replace(':USERS:','USERS:')

$yaml | select -first 3

#finally convert $yaml to type string, so that the convertfrom-yaml function works 

$yaml = $yaml | out-string 

$obj3 = ConvertFrom-Yaml $yaml -AllDocuments

#this object should have 2 parts to it Groups and Users

#key value pairs, keys are the ID numbers of the groups, values are Hashtables of the properties/values for each group

$yammergroups = $obj3.GROUPS.values
#creates one item per group, and allows you to get to each individual property

#$yammergroups.keys #shows the properties available

#setup final object to use to export to CSV
$yammerGroupsExport = @()

$yammergroups | foreach-object {
	$yamGrp = [PSCustomObject]@{
			Id =  $_.id
			Type = $_.type
			Name = $_.name
			UploadedFileCountsYammerFiles = $_.uploaded_file_counts.yammer_files
			UploadedFileCountsSharePointFiles = $_.uploaded_file_counts.sharepoint_files
			LastMessageAt = $_.last_message_at
			OtherCommunityGuests = $_.other_community_guests -join ';'  #I didn't have any items in this property in my YML file so not sure of the properties.
			GroupAdminsWithOutCreation = $_.group_admins.without_o365_creation_rights -join ';' #works but creates one row for this group per people without creation
			GroupAdminsWithCreation =  $_.group_admins.with_o365_creation_rights -join ';'
			PrivacySetting = $_.privacy_setting
			State = $_.state
			ApproxMessagesCount = $_.approximate_messages_count
			O365connected = $_.o365_connected
			MemberCountsCommunityGuests = $_.member_counts.community_guests
			MemberCountsInternal = $_.member_counts.internal
			ActiveCommunityGuests = $_.active_community_guests -join ';'  #I didn't have any items in this property in my YML file so not sure of the properties.
	#Write-host $yamGrp
	$yammerGroupsExport += $yamGrp

#use following to figure out the properties for items of type System.Collections.Generic.List`1[System.Object] , it will show the keys to get the individual values 
write-host $_.group_admins.keys
write-host $_.group_admins.values 
write-host $_.group_admins.without_o365_creation_rights
write-host $_.group_admins.with_o365_creation_rights 
$xx = $_.group_admins.with_o365_creation_rights -join ';'
write-host $xx
write-host $xx.gettype()
#use following to figure out the properties for items of type System.Collections.Hashtable, it will show the keys to get the individual values 
write-host $_.active_community_guests.keys
write-host $_.active_community_guests.values

#I did figure out that if the YML document contains [] that means there are no values
#    e.g.   active_community_guests: [] 
# if there are values in a property like this they show up as
#          without_o365_creation_rights:
#				- email address removed for privacy reasons
#				- email address removed for privacy reasons


$currentDate = (get-date -Format "yyyy-MM-dd-hh-mm-ss")
$thisFilename = $pathToSaveCSVto+"\yammerNativeMode-groups-"+$currentDate+".csv"
$yammerGroupsExport | Export-CSV $thisFilename -NoTypeInformation
write-host $thisFilename
$thisFilename = ""
write-host "NOTE : column values of 'System.Collections.Generic.List`1[System.Object]' and 'System.Collections.Hashtable' indicated NO value, I believe you can ignore them in the exported CSV"

#now do the users
$yammerusers = $obj3.USERS.values

$yammerUsersExport = @()

$yammerusers | foreach-object {
	$yamUsr = [PSCustomObject]@{
			Name = $_.name
			Email = $_.email
			Internal = $_.internal
			State = $_.state
			Roles = $_.roles -join ';'    #I didn't have any items in this property in my YML file so not sure of the properties.
			LastDateAccessed = $_.last_date_accessed
			PrivateMessagFiles = $_.private_message_files
			CommunityMessageCount = $_.community_message_count
			PrivateMessageCount = $_.private_message_count
			AADState = $_.AAD_state
	#Write-host $yamUsr
	$yammerUsersExport += $yamUsr

	#write-host $_.roles.keys
	#write-host $_.roles.values

$currentDate = (get-date -Format "yyyy-MM-dd-hh-mm-ss")
$thisFilename = $pathToSaveCSVto+"\yammerNativeMode-users-"+$currentDate+".csv"
$yammerUsersExport | Export-CSV $thisFilename -NoTypeInformation
write-host $thisFilename
$thisFilename = ""
write-host "NOTE : column values of 'System.Collections.Generic.List`1[System.Object]' and 'System.Collections.Hashtable' indicated NO value, I believe you can ignore them in the exported CSV"


@Brian Lyttle , I hope this power shell compliments your GitHub "Native Mode Alignment Tool Report Converter (NMARC)" https://github.com/microsoft/nmarc 
I would be happy for any suggestions / improvements to this script  so that those who have to align their Yammer networks, but do not understand Visual studio or how to use it have another option.


I've just used this script to get ready to align a Yammer network started in 2017 with 93 communities and 1798 users.



Thanks Dorje. Just back from vacation and appreciate the effort here. The product group have been given the feedback on the general challenges with providing only YAML output.

There is an unofficial build in the Store under my account at aka.ms/getnmarc. It's unlikely to be published under the official Microsoft account. Given the sensitivity of the alignment report contents, building from source was the better option. I wanted folks to be in complete control of how the data was being processed. e.g. I don't make any network calls from the NMARC tool, but people should always assume that this is the case. Infosec reviews would check this.

@Brian Lyttle thanks so much for taking the time to reply, and passing these comments on to the product team.
I hope you had a great vacation. Folks in our line of work don't get enough of them :)


I'm sure your prebuilt downloadable version of the NMARC code will help a lot of people.

Unfortunately some organisations like mine block the Microsoft Store. 


You mention the sensitivity of the "alignment report contents" and "infosec reviews". I used to work for a Financial Securities software development house so I can take a guess at what you're talking about. But lots of people charged with managing the digital workplace in massive, large and small organisations won't understand. Please feel free to elaborate if you would like to.


Really appreciate your time and effort, as well as that of all the product team working on Yammer. Thank you.