Forum Widgets
Latest Discussions
Bulk update Azure AD with user attributes from CSV
I am looking for a way to update user attributes (OfficePhone and Department) for about 500 users from a CSV to AzureAD using a powershell. Does anyone know of a script that I could use? I am new here and if I have not given enough information, please let me know. I tried using Set-AzureADUser piping records using a foreach statement from a csv that I imported, but it was throwing up errors. Thanks! JacobSolvedjebujohnMay 08, 2020Copper Contributor195KViews4likes69CommentsCan I Connect to O365 Security & Compliance center via powershell with MFA on?
I currently use the below script to connect to the S&C Center. This does not work with MFA. I was wondering if there is an Updated Module that I could use that supports modern authentication? $Credential = get-credential -Credential username.com $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid -Credential $Credential -Authentication Basic -AllowRedirection Import-PSSession $Session -AllowClobber –DisableNameCheckingSolvedRobert WoodsMay 10, 2017Steel Contributor57KViews1like42CommentsWindows 11 assigned access - setting kiosk mode over powershell and WMI
Hey guys, so currently as this article states, kiosk multi app mode in Intune for windows 11 is on the roadmap, but there is no ETA, when it comes live.https://techcommunity.microsoft.com/t5/windows-it-pro-blog/multi-app-kiosk-mode-now-available-in-windows-11/ba-p/3845558 I then tried as this article shows (https://learn.microsoft.com/en-us/windows/configuration/lock-down-windows-11-to-specific-apps ) to run the stated powershell script with my own configured XML file, as you can see here: $nameSpaceName="root\cimv2\mdm\dmmap" $className="MDM_AssignedAccess" $obj = Get-CimInstance -Namespace $namespaceName -ClassName $className Add-Type -AssemblyName System.Web $obj.Configuration = [System.Web.HttpUtility]::HtmlEncode (@" <?xml version="1.0" encoding="utf-8" ?> <AssignedAccessConfiguration xmlns="http://schemas.microsoft.com/AssignedAccess/2017/config" xmlns:win11="http://schemas.microsoft.com/AssignedAccess/2022/config"> <Profiles> <Profile Id="dca70007-6874-49b3-930f-26ead1d85918"> <AllAppsList> <AllowedApps> <App AppUserModelId="Citrix.Workspace" rs5:AutoLaunch="true"> <App AppUserModelId="MSEdge" /> <App AppUserModelId="Microsoft.WindowsCalculator_8wekyb3d8bbwe!App" /> <App AppUserModelId="Microsoft.Windows.Explorer" /> </AllowedApps> </AllAppsList> <win11:StartPins> <![CDATA[ {"pinnedList": [ {"desktopAppLink":"%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Citrix Workspace.lnk"}, {"desktopAppLink":"%ALLUSERSPROFILE%\\Microsoft\\Windows\\Start Menu\\Programs\\Microsoft Edge.lnk"}, {"packagedAppId":"windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel"}, {"desktopAppLink":"%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\File Explorer.lnk"}, {"packagedAppId":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"} ]} ]]> <win11:StartPins/> <Taskbar ShowTaskbar="true"/><Taskbar/> </Profile> </Profiles> <Configs> <Config> <AutoLogonAccount/> <DefaultProfile Id="{c374b80f-6aea-4c02-b1db-7bb1dfc4fe84}"/> </Config> </Configs> </AssignedAccessConfiguration> "@) Set-CimInstance -CimInstance $obj but im getting following errors: Get-CimInstance: C:\Users\michael.woerner\GitHub-Repo\Github_Work\Intune\Scripts\Kiosk-XML-WMI.ps1:3:8 Line | 3 | $obj = Get-CimInstance -Namespace $namespaceName -ClassName $classNam … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Zugriff verweigert. InvalidOperation: C:\Users\michael.woerner\GitHub-Repo\Github_Work\Intune\Scripts\Kiosk-XML-WMI.ps1:5:1 Line | 5 | $obj.Configuration = [System.Web.HttpUtility]::HtmlEncode | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | The property 'Configuration' cannot be found on this object. Verify that the property exists and can be set. Set-CimInstance: C:\Users\michael.woerner\GitHub-Repo\Github_Work\Intune\Scripts\Kiosk-XML-WMI.ps1:44:30 Line | 44 | Set-CimInstance -CimInstance $obj | ~~~~ | Cannot bind argument to parameter 'InputObject' because it is null. Can you guys help me with that?MichaelWAug 09, 2023Brass Contributor13KViews0likes37CommentsNeed a PowerShell Script to add multiple users to Azure Ad using csv file.
Script that i have tried its showing the below error. And Unable to fix it. Myscript:- #Import-Module AzureAD #Already installed # Set the path to your CSV file $csvPath = "C:\Users\pathto\newuserscript.csv" # Set the desired password length $passwordLength = 10 # Read the CSV file $users = Import-Csv -Path $csvPath # Connect to Azure AD #Connect-AzureAD # Loop through each user in the CSV file foreach ($user in $users) { # Generate a random password $password = [System.Web.Security.Membership]::GeneratePassword($passwordLength, 2) # Create a new user object $newUserParams = @{ DisplayName = $user.DisplayName UserPrincipalName = $user.UserPrincipalName PasswordProfile = @{ Password = $password ForceChangePasswordNextSignIn = $true } } # Add the user to Azure AD New-AzureADUser @newUserParams # Output the user details and password to the console Write-Output "User created: $($user.DisplayName) ($($user.UserPrincipalName))" Write-Output "Password: $password" # Export the user details and password to a CSV file $output = [PSCustomObject]@{ DisplayName = $user.DisplayName UserPrincipalName = $user.UserPrincipalName Password = $password } $output | Export-Csv -Path "C:\Users\pathto\userlistpw.csv" -force -NoTypeInformation } Error:- Unable to find type [System.Web.Security.Membership]. At line:13 char:17 + $password = [System.Web.Security.Membership]::GeneratePassword($p ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Web.Security.Membership:TypeName) [], RuntimeException + FullyQualifiedErrorId : TypeNotFound New-AzureADUser : Cannot bind argument to parameter 'DisplayName' because it is null. At line:26 char:17 + New-AzureADUser @newUserParams + ~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [New-AzureADUser], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Open.AzureAD16.PowerShell.NewUser User created: () Password: Note:- My csv file contain only Display name , UPN , Block sign in column filled, Else other are blank. THANK YOU!!Solved13KViews0likes29CommentsDisable and removal of Computer accounts
Hi, I made a script to disable old computer accounts. My Sysadmin asked me to disable after 180 days and remove them after a year. My goal is to disable computer accounts after 180 days and export to CSV then delete computer accounts after 356 days and export to CSV. Import-Module ActiveDirectory # Set the Parameters since last logon $DaysInactive = 180 $InactiveDate = (Get-Date).Adddays(-($DaysInactive)) $ForDisableLog = "C:\scripts\ComputerAccounts\Logs\For_Disable$((Get-Date).ToString('dd-MM-yyyy')).csv" #------------------------------- # FIND INACTIVE COMPUTERS #------------------------------- # Automated way (includes never logged on computers) $Computers_For_Disable = Search-ADAccount -AccountInactive -DateTime $InactiveDate -ComputersOnly -SearchBase "DC=staff ,DC=local" | Where-Object {$_.distinguishedname -notlike "*,OU=Servers,*"} | Where-Object {$_.distinguishedname -notlike "*,OU=Test,*"} | Where-Object {$_.distinguishedname -notlike "*,OU=IT,*"} | Where-Object {$_.distinguishedname -notlike "*,OU=Laptops,*"} | Where-Object {$_.distinguishedname -notlike "*,CN=Computers,*"} | Select-Object Name, LastLogonDate, Enabled, DistinguishedName #------------------------------- # REPORTING #------------------------------- # Export results to CSV $Computers_For_Disable | Export-Csv "C:\scripts\ComputerAccounts\Logs\For_Disable$((Get-Date).ToString('dd-MM-yyyy')).csv" -NoTypeInformation -Encoding UTF8SolveddannytveriaAug 26, 2021Brass Contributor8.8KViews0likes29CommentsHelp with Watcher
Hey guys, some of you can help me to check what is wrong with this script? thank you in advance! # Cartella da monitorare (stessa cartella) $cartellaDaMonitorare = "C:\TEST" # Crea un registro per i file già rinominati $registroFileRinominati = "C:\TEST\registro.txt" # Funzione per rinominare i file MSG con data e ora function Rinomina-FileMSG { param ( [string]$file ) if ($file -match "\.msg$" -and -not $registroFileRinominati.ContainsKey($file)) { $now = Get-Date -Format "yyyyMMddHHmm" $nomeFile = [System.IO.Path]::GetFileNameWithoutExtension($file) $estensione = [System.IO.Path]::GetExtension($file) $nuovoNome = "${now}_${nomeFile}${estensione}" Rename-Item -Path $file -NewName $nuovoNome Write-Host "Rinominato $file in $nuovoNome" $registroFileRinominati[$file] = $true } } # Crea un oggetto FileSystemWatcher per monitorare la cartella $watcher = New-Object System.IO.FileSystemWatcher $watcher.Path = $cartellaDaMonitorare $watcher.Filter = "*.msg" $watcher.IncludeSubdirectories = $true $watcher.EnableRaisingEvents = $true # Azione da intraprendere quando viene rilevato un nuovo file $action = { $changeType = $Event.SourceEventArgs.ChangeType $file = $Event.SourceEventArgs.FullPath if ($changeType -eq "Created" -or $changeType -eq "Renamed") { Rinomina-FileMSG -file $file } } # Associa l'azione all'evento Created e Renamed Register-ObjectEvent -InputObject $watcher -EventName Created -Action $action Register-ObjectEvent -InputObject $watcher -EventName Renamed -Action $action # Attendi che lo script venga interrotto Write-Host "Waiting for new MSG files..." while ($true) { Start-Sleep -Seconds 30 }SolvedTurion986Aug 31, 2023Copper Contributor3.1KViews0likes28Commentsadd just one user to many groups
Hi please help me to make a script in PowerShell to add just one user to many groupssofo-83Mar 30, 2022Copper Contributor3.9KViews1like27CommentsUsing powershell to create folders within users onedrive
Hi all, I'm experiencing several issues with different PowerShell versions when trying to create folders in OneDrive for users in bulk. PowerShell 5.1 does not recognize Connect-PnPOnline. PowerShell 7 does not recognize Connect-SPOService. I have been following the instructions from this guide, which worked on my previous device. However, I’m unable to get it to work on my new device. My goal is to create folders within specific users' OneDrive accounts. Could you please assist me in resolving this? Thank you!AB21805Jul 03, 2024Bronze Contributor2.5KViews0likes26CommentsExport des "Date de la dernière connexion" compte invités sur Azure AD
Bonjour, je vous contacte car nous voudrions faire du ménage sur notre Tenant, quand je cliques sur des utilisateurs je peux observer dans l'azure AD la date de la dernière connexion au compte. Je voudrais faire un export de ces dernières connexions pour chaque user Guest de notre Tenant. Je ne trouve pas la commande Powershell pour effectuer ceci, pourriez m'aider ? Merci d'avanceManflo1603Mar 25, 2022Brass Contributor9.1KViews1like25CommentsHelp with parameter for Search-UnifiedAuditLog
Hi, Disclaimer: I am new to PowerShell, hence why I turn here for your input. Background: I'm creating a Power BI dashboard based on data exported from the O365 Audit Log. For the moment, I'm not using the recently launched API, but a daily scheduled PowerShell script to export the data. Everything works fine with one exception: Issue: The maximum number of objects that can be returned in one query is 5000 (see article for details). We have a fairly small tenant, so I have divided the cmdlet to run twice to cover 24h (AM+PM), that gives us 10k rows which usually is enough. Now the exception is when we run SharePoint backups via Metalogix. The operation is of course walking through every single file which results in logs well above 10k rows. Solution? What I want to achieve is to exclude the user account associated with the backup operation, to only return "relevant" objects/events. I was hoping to archive this by using the parameters provided in the cmdlet, but with my limited knowledge I can't figure it out. I can pass user ID's to include, but would this also allow me to exclude by user ID? If so, how? I can always divide the cmdlet to run more than twice per 24h, allowing more objects to be returned, but I hope there is a better solution to this. https://technet.microsoft.com/en-us/library/mt238501%28v=exchg.160%29.aspx?f=255&MSPPError=-2147217396 Many thanks!SolvedPontus TApr 27, 2017Iron Contributor31KViews0likes24Comments
Resources
Tags
- Windows PowerShell1,126 Topics
- powershell335 Topics
- office 365268 Topics
- Azure Active Directory135 Topics
- Windows Server126 Topics
- SharePoint125 Topics
- windows96 Topics
- azure91 Topics
- exchange85 Topics
- Community54 Topics