Recent 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! JacobSolved196KViews5likes72CommentsCan 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 –DisableNameCheckingSolved57KViews1like42CommentsWindows 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?14KViews0likes37CommentsNeed 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 UTF8Solved9KViews0likes29CommentsHelp 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 }Solved3.3KViews0likes28CommentsUsing 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!2.7KViews0likes26CommentsExport 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'avance9.2KViews1like25CommentsHelp 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!Solved31KViews0likes24Comments.ps1 script: how to loop in a range of dates
Hi all, I have to copy the content of the folders: C:\mypath\YYYYDDMM\myfolder1 into one folder destination. And: YYYYMMDD is from 20140101 to 20211231 I'm struggling to find a way to increment day by day my loop, extract day.month.year from the date and then compose the new string for my path...... can somebody help me? thanks!!!Solved4.9KViews0likes23CommentsProblem with my script, dont execute
Hello to everyone I have a script that is not working for me and I do not understand why ?, my script tries to run a ping to selected machines as long as the computer is in a valid network to perform the ping and finally gives me a report in a file, in If a ping fails with a machine, I will display an alert window to take actions, but I really do not understand what happens with the script if you can guide me please, thank you very much. +++ Powershell script++++ Add-Type -AssemblyName PresentationCore,PresentationFramework $names = Get-content "C:\Servers.txt" $subname=" " $chequea="no" $dia = Get-date $ButtonType = [System.Windows.MessageBoxButton]::OK $MessageIcon = [System.Windows.MessageBoxImage]::Error $MessageTitle = "Falla de Alcance por Ping" #$ipV4 = Test-Connection -ComputerName (hostname) -Count 1 | Select -ExpandProperty IPV4Address $ipV4 = (Get-NetAdapter -Physical | where status -eq 'up' | Get-NetIPAddress).IPv4Address Write-Host $ipV4.IPAddressToString #Write-Verbose $ipV4.IPAddressToString if ($ipV4.GetAddressBytes()[0] -eq "192" -and $ipV4.GetAddressBytes()[1] -eq "168" -and $ipV4.GetAddressBytes()[2] -eq "5" ){ $chequea="si" } if ($ipV4.GetAddressBytes()[0] -eq "192" -and $ipV4.GetAddressBytes()[1] -eq "168" -and $ipV4.GetAddressBytes()[2] -eq "6" ){ $chequea="si" } if ($ipV4.GetAddressBytes()[0] -eq "10" -and $ipV4.GetAddressBytes()[1] -eq "212" -and $ipV4.GetAddressBytes()[2] -eq "134" ){ $chequea="si" } if($chequea -eq "si"){ $Output+="$dia : " foreach ($name in $names){ if (Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue){ $Output+= "$name ====>> UP || " Write-Host "$name ====>> UP " #Write-Verbose "$name ====>> UP " } else{ $Output+= "$name ====>> DOWN || " Write-Host "$name ====>> DOWN " #Write-Verbose "$name ====>> DOWN " if ($name -eq "8.8.8.8"){ $subname="DNS Google" } if ($name -eq "www.google.com"){ $subname="Dominio Google" } if ($name -eq "192.168.5.1"){ $subname="Firewall" } if ($name -eq "192.168.5.2"){ $subname="Server 10" } if ($name -eq "192.168.5.30"){ $subname="Server 8" } if ($name -eq "192.168.5.29"){ $subname="Server 9" } if ($name -eq "192.168.5.52"){ $subname="Server 7" } if ($name -eq "192.168.6.16"){ $subname="Server 1" } if ($name -eq "192.168.5.94"){ $subname="Server 2" } if ($name -eq "192.168.5.102"){ $subname="Server 3" } if ($name -eq "192.168.5.43"){ $subname="Server 4" } if ($name -eq "192.168.5.124"){ $subname="Server 5" } if ($name -eq "192.168.6.250"){ $subname="Impresora Wifi" } if ($name -eq "192.168.5.250"){ $subname="Impresora Xerox " } $MessageBody = "Conexion Perdida con el IP: $name, $subname" $oReturn=[System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon) } } $Output | Out-file "C:\PingResult.txt" -Append }4.5KViews0likes23CommentsNeed to convert a text file into a CSV
I have a text file from payroll that includes all active employees and their relevant information such as Phone Number, Office Location etc. I need to convert this file into a CSV so I can more easily utilize the data in another script. Here is an example of what the file contents look like. The hyphens depict the length of each column. Once I can convert the file into a proper CSV then I plan to being using the CSV for creating/updating AD accounts.5KViews0likes22CommentsTrying to Install-Module AzureAD but Get-PSRepository "WARNING: Unable to find module repositories."
I am running PSVersion 5.1.16299.431 and have set my proxy using NetSH WinHTTP Set Proxy proxy-server="my.proxy.server" I would like to "Install the preview version of the Azure Active Directory Module for Windows PowerShell" as per https://support.office.com/en-gb/article/Manage-who-can-create-Office-365-Groups-4c46c8cb-17d0-44b5-9776-005fced8e618. However, on running Install-Module AzureAD I see "PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'AzureAD'. Try Get-PSRepository to see all available registered module repositories." I can run Register-PSRepository -Default without issue but when I run Get-PSRepository I am faced with "WARNING: Unable to find module repositories." I have been able to run update-help, so I assume I can get online ok. Finally, I tried to Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ -Proxy my.proxy.server but see the message, "Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable. Please try again later." Can someone please advise what I need to do to be able to successfully Install-Module AzureAD?Solved483KViews0likes22CommentsGet-StartApps : The term 'Get-StartApps' is not recognized as the name of a cmdlet, function, script
I have a command such as (Get-StartApps | Where-Object name -eq 'Notepad').AppId or just simply Get-StartApps which works just fine via PowerShell ISE. I, on the other hand, am trying to run it via VBA in Excel/Access.... and do so by using WScript.Shell CreateObject("WScript.Shell").Run "powershell -executionpolicy RemoteSigned -command ""Get-StartApps | Where-Object name -eq 'Notepad';Start-Sleep -Seconds 8;""", 1, True where I then receive the error : Get-StartApps : The term 'Get-StartApps' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Get-StartApps | Where-Object name -eq 'Notepad';Start-Sleep -Seconds ... + ~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-StartApps:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException I can simplify it to bare minimum CreateObject("WScript.Shell").Run "powershell -executionpolicy RemoteSigned -command ""Get-StartApps;Start-Sleep -Seconds 8;""", 1, True and it still returns Get-StartApps : The term 'Get-StartApps' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Get-StartApps;Start-Sleep -Seconds 8; + ~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-StartApps:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException (The Start-Sleep -Seconds 8; is only there for debugging purposes, the command errs without it being present just the same.) I even thought maybe it was a 32-bit vs. 64-bit issue and tried explicitly specifying the PS exe to use C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe but it made no difference, both failed the same. Now I've used such an approach to do all sorts of other thing in PS via VBA without issue. This truly is specifically related to the Get-StartApps CmdLet. Is there something special about it that makes it not accessible? Anyone have any ideas? Maybe an alternate way to retrieve a programs AppId, that's what I'm ultimately after?! Thank you for your help in advance. DanielSolved3.4KViews0likes21CommentsPowershell: get data from MsOnline
Hi all, I would extract some "basic" data like "UserPrincipalName, DisplayName, licenses, islicensed, creation date, last activation date" and others "nested" like AlternateEmailAddresses. If possible, but only if possible without struggling, also the expiry date of the licenses... More, I would filter only some kind of licenses, not everything but only: #EXCHANGESTANDARD #EXCHANGEENTERPRISE #O365_BUSINESS #O365_BUSINESS_ESSENTIALS #O365_BUSINESS_PREMIUM #SPB #ATP_ENTERPRISE #POWER_BI_PRO I tried several attempts without any success... A further step could be (but maybe not possible, perhaps difficult I understand) to get the licenses in separate columns, one for each type, to have a better ovwerview of the status of the accounts... May someone help? thanks a lot for your support mfSolved4.2KViews0likes21CommentsEXO command 'New-UnifiedGroup' issue on Linux version Powershell
I use below ExchangeOnline powershell (EXO v3.3) to create M365 group. New-UnifiedGroup -DisplayName "test_group" -Owner "<owner email address>" -PrimarySmtpAddress "<primary address>" It's working on Windows version powersehll (7.x) without problem. But when I use exact same command (with same paramters) to create new M365 group under Linux version powershell, I just got below error, EXO module version is same as v3.3 New-UnifiedGroup: |Microsoft.Exchange.Configuration.Tasks.TaskException|The group can't be created Because it does not show any reason, I have no idea what's wrong with the command.2.6KViews0likes20CommentsDownload Specific Files From Link
https://www.fbi.gov/wanted/topten/alejandro-castillo/download.pdf Hi here is the link i need to download the file , between the /topten and /download.pdf is the person name. And the website will update everyday so if i want download all the file how can i write. Cuz if i just use the link https://www.fbi.gov/wanted/topten is will jump out the message:Content-Disposition header not found for URL: https://www.fbi.gov/wanted/toptenSolved2.7KViews0likes20Comments
Events
Recent Blogs
- One new resource, logging improvements and bugfixes. This is what SharePointDsc v5.2 is bringing to the table!May 12, 20227.5KViews1like0Comments
- 2 MIN READThis article describes a solution of an issue I have been troubleshooting today, where switching to an AllSigned execution policy resulted in the "This publisher is explicitly not trusted on your sys...Mar 18, 20226.4KViews1like1Comment