Powershell

/Powershell

Powershell how to read a csv file

Here is how we can get information in a csv file format using Export-CSV command.

Get-ADComputer -Filter { name -like “*searchString*”} | select Name | Export-CSV c:\temp\filename.csv

Once we have the csv file the best command to read eventually this information is not Get-Content but Import-CSV.  Import-CSV reads the individual entries in CSV file and keeps it as an object. So we have to use the format object.atribute to read the value, e.g. as the column header of my csv file is Name, I can read the csv file using that attribute.

ForEach ($Computer In $Computers){Write-Host $Computer.Name}

By |2018-09-19T12:50:03+00:00September 19th, 2018|Active Directory, Powershell|0 Comments

Useful PowerShell Commands for Office 365 Administration

Users

Get-MsolUser -UserPrincipalName xxxx

Groups

Get-Group -Identity xxxx

Get-DistributionGroup -Identity xxxx

Remove-UnifiedGroup -Identity

Set-DistributionGroup –Identity domain.com/OU1/OU2/OU3/group-name -AcceptMessagesOnlyFromSendersOrMembers((Get-DistributionGroup -identity domain.com/OU1/OU2/OU3/group-name).AcceptMessagesOnlyFromSendersOrMembers + “group-name@domain.com“)

Set-DistributionGroup -Identity domain.com/OU1/OU2/OU3/group-name -RequireSenderAuthenticationEnabled $true

Azure AD Sync

(Get-MSOLCompanyInformation).DirectorySynchronizationEnabled

Set-MsolDirSyncEnabled –EnableDirSync $true

Set-MsolDirSyncEnabled –EnableDirSync $false

To run form domain controller where ADSync is installed:

Start-ADSyncSyncCycle -PolicyType delta

Start-ADSyncSyncCycle -PolicyType initial

Mailbox

Get-Mailbox user@domain.com

Get-MailboxStatistics user@domain.com

Get-MailboxPermission user@domain.com | where {$_.isInherited -eq $false}

Get-RecipientPermission -Identity user@domain.com

Get-Mailbox -SoftDeletedMailbox -ResultSize Unlimited

By |2018-05-28T11:22:04+00:00May 15th, 2018|Office 365, Powershell|0 Comments