Skip Navigation

InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)P
PowerShell

Members
0
Posts
4
Created
3 yr. ago

A community dedicated to Microsoft PowerShell.

Rules

  1. Everyone is welcome.
  2. Treat others with respect at all time.
  3. When asking questions, please try to show what you have done, including code.

🌉 bridged from !powershell@lemmy.world by Tidepool

What have you done with PowerShell this month?

As a way to kick off migration from Reddit to Lemmy, let's start with a classic thread. So, what have you done with PowerShell this month?

For bonus imaginary points, have you done anything in regards to the Great Reddit Migration?

Powershell functions and aliases in constrained language mode

Hey all, I come from bash and zsh and i'm generally used to tailoring and customizing my experience to what suits me. I want to do the same for my work laptop. I have created a profile.ps1 but due to constrained language mode I cant seem to set aliases or functions because it cant dot source it. What are some viable alternatives? Disclaimer, I'm not looking to bypass the security and policies set here, just alternatives to try and make the experience easier

Get-AzureADUser : Cannot bind argument to parameter 'ObjectId' because it is null.

 
#Install-Module -Name AzureADPreview
#Install-Module -Name ActiveDirectory
Import-Module ActiveDirectory
Import-Module AzureADPreview

$cred = Get-Credential

Connect-AzureAD -Credential $cred

$users = Get-ADUser -SearchBase ‘OU=Test Users, OU=CO Users, DC=CO ,DC=domain, DC=org’ -filter *

foreach ($user in $users)
{
    $email = $user.samaccountname + '@co.domain.org'
    $UserPrincipalName = $email

    $newemail = "SMTP:"+$email
    $mailattribute = $email
    #$DisplayName = $user.displayName
    #$sam = $_SamAccountName

    $account = Get-AzureADUser | Where-Object {$_.UserPrincipalName -eq $UserPrincipalName}
    Write-Host "UserPrincipalName: $UserPrincipalName"
    Get-AzureADUser -ObjectId $account.ObjectId | select Account }
Add-AzureADGroupMember -ObjectId (Get-AzureADGroup -SearchString "OfficeUsersTest").ObjectId -RefObjectId $account.ObjectId

This is going to be a script that runs nightly to double checkthat certain atributes have been created for new User accounts.