Skip to content

Instantly share code, notes, and snippets.

View kevinblumenfeld's full-sized avatar
🎯
Focusing

Kevin Blumenfeld kevinblumenfeld

🎯
Focusing
View GitHub Profile
$OutFile = "C:\Temp\PermissionExport.txt"
"DisplayName" + "," + "Alias" + "," + "Primary SMTP" + "," + "Full Access" + "," + "Send As" + "," + "Send on Behalf" | Out-File $OutFile -Force
$Mailboxes = Get-Mailbox -ResultSize:Unlimited | Select Identity, Alias, DisplayName, DistinguishedName, primarysmtpaddress
ForEach ($Mailbox in $Mailboxes)
{
$SendAs = Get-ADPermission $Mailbox.DistinguishedName | ? {$_.ExtendedRights -like "Send-As" -and $_.User -notlike "NT AUTHORITY\SELF" -and !$_.IsInherited} | % {$_.User}
$FullAccess = Get-MailboxPermission $Mailbox.Identity | ? {$_.AccessRights -eq "FullAccess" -and !$_.IsInherited} | % {$_.User}
$sendbehalf=Get-Mailbox $Mailbox.Identity | select-object -expand grantsendonbehalfto | select-object -expand rdn | % {$_.User}
if (!$SendAs -and !$FullAccess -and !$sendbehalf){continue}
$hash = @{}
$text = 'lorem ipsum dolor sit amet consectetur adipiscing elit'
-split $text | ForEach-Object {
write-host "3: $3"
write-host "U: $_"
$1 = $2
$2 = $3
get-mailbox -resultsize Unlimited| select RetentionPolicy, count| group-object -property RetentionPolicy| sort-object count -Descending|
select name,count |
Export-Csv .\lausd\ProductionPulls\RetentionPolicyAssignmentCounts.csv -NoTypeInformation
if ($BaseSkuRemove) {
if ((Get-MsolAccountSku |where {$_.accountskuid -eq $PrimarySku}).consumedunits -lt (Get-MsolAccountSku |? {$_.accountskuid -eq $PrimarySku}).activeunits) {
for ($i = 0; $i -lt $BaseSkuRemove.count; $i++) {
Write-Host "NOT IN IF: $($user.licenses.accountskuid) $($BaseSkuRemove[$i])"
if ($user.licenses.accountskuid -contains $BaseSkuRemove[$i]) {
Write-Host "IN IF: $($user.licenses.accountskuid) $($BaseSkuRemove[$i])"
# Collect options of the SKU to add in the new sku THEN we will remove the old SKU
ForEach ($License in $user.licenses | Where {$_.AccountSkuID -eq $SkuE3}) {
$License.ServiceStatus | ForEach {
if (($_.ProvisioningStatus -eq "Disabled") -and ($_.ServicePlan.ServiceName -notin "FLOW_O365_P2", "POWERAPPS_O365_P2")) {
Function New-DynamicParameter {
[CmdletBinding(PositionalBinding = $false, DefaultParameterSetName = 'DynamicParameter')]
Param
(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'DynamicParameter')]
[ValidateNotNullOrEmpty()]
[string]$Name,
[Parameter(ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'DynamicParameter')]
<#
.SYNOPSIS
Helper function to simplify creating dynamic parameters
.DESCRIPTION
Helper function to simplify creating dynamic parameters.
Example use cases:
Include parameters only if your environment dictates it
Include parameters depending on the value of a user-specified parameter
function Get-CloudSkuTable {
<#
.Synopsis
Short description
.DESCRIPTION
Long description
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
function Set-LACloudLicenseV2 {
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
Param
(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string[]] $pipelineUser
)
DynamicParam {
$DynamicParameters = @(
Service
AAD_PREMIUM
AAD_PREMIUM_P2
ADALLOM_S_O365
ADALLOM_S_STANDALONE
ATP_ENTERPRISE
BI_AZURE_P1
BI_AZURE_P2
CRMIUR
CRMSTANDARD
FORMS_PLAN_E5
STREAM_O365_E5
THREAT_INTELLIGENCE
Deskless
FLOW_O365_P3
POWERAPPS_O365_P3
TEAMS1
ADALLOM_S_O365
EQUIVIO_ANALYTICS
LOCKBOX_ENTERPRISE