Scenario. We have different customer with different login.
Looking to create an PS script to put all the information into one or two csv.
How can i loop using an text file with the company names ?
what is the best way to “merge” csv files ?
$customer = “company”
##Username login to portal.office.com
$User = “login name”
##Password files. Planning on going through all different customer to get them encrypted
$pass = “C:\password\password-$customer.txt”
Passing credentials and password to O365
$cred=New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $User, (Get-Content $pass | ConvertTo-SecureString)
##Import module
import-module msonline
##Connecting to the service with credentials
Connect-MsolService -Credential $cred
##Definer where to save csv
$savetocsv = “C:\report\user-$customer.csv”
$savetocsv2 = “c:\report\licens-$customer.csv”
##Getting the information based on user
Get-MsolUser -all | select userprincipalname,islicensed,{$_.Licenses.accountskuid} |
Add-Member -MemberType NoteProperty -Name Company -Value “$customer” -PassThru |
export-csv $savetocsv -NoTypeInformation
##Getting the information based on licenses information
Get-MsolAccountSku | select accountskuid,activeunits,consumedunits |
Add-Member -MemberType NoteProperty -Name Company -Value “$customer” -PassThru |
export-csv $savetocsv2 -NoTypeInformation
What is your goal? Are you creating a report? The AccountSku information is a key more than association with each user, your data would look like this:
The above doesn’t make sense to me, but it’s certainly possible to dump data like this to a CSV. It would just help to understand what your end result would look like.
I have a script in place that adds 0365 Licenses based on a user’s membership in an Active Directory Group. This portion on the script works. I’m looking for a method to remove the license if a user is not a member of an Active Directory Group.