User Profile
farismalaeb
Iron Contributor
Joined 6 years ago
User Widgets
Recent Discussions
Re: powershell for microsoft 365
shahzadms Hi and welcome to the club. This is something you will enjoy and hate at the same time. There are a lot of youtube channels to teach PowerShell. Check this video https://www.youtube.com/watch?v=UVUd9_k9C6A&t=10459s Also, you can read some online articles... But the main thing first is to see how you like to learn. Do you prefer listening, watching, or reading? Anyway. PowerShell is free, and the IDE (the interface you use to write a script) is also free such as VSCode or ISE. Check this https://www.amazon.com/PowerShell-Office-365-Automate-administrative/dp/1787127990 One of the good ways to learn is to create a scenario. for example. If you need to automate AAD User creation for your organization, try it. Ask here or in other channels, we are all here to share, learn and help. Learn About Graph API SDK, as you can control Microsoft 365 solutions using it. The best way to learn is to read about the thing u want to do and then try, fail, try and succeed. There is a nice book here that can teach you PowerShell for Sysadmin https://vdoc.pub/documents/powershell-for-sysadmins-workflow-automation-made-easy-6chuotvmd870820Views0likes0CommentsRe: Get Logon Server From List Of Computers
charlie4872 You dont need to use the variable before the foreach. Use this. $computers = get-content C:\MyFile.txt foreach ($computer in $computers){ $results=invoke-command -computer $computer -scriptblock {$env:logonserver} Add-Content C:\MyResult.txt -Value $results }4.7KViews0likes2CommentsRe: Send-mailmessage not working in server
rbn_neu Timeout, are you sure that the tenant is enabled for Basic Auth. Also make sure that the connection is allowed to connect to this port by the firewall. Why are you using SSL3? It's dead, and Microsoft doesn't support it. Get more info here https://adamtheautomator.com/office-365-direct-send/ Test the connectivity by running Test-NetConnection -ComputerName smtp.office365.com -Port 587 Also, why use the Send-MailMessage? it's obsolete and no longer supported, the cmdlet is archived. I think you need to use the Graph API to send emails. https://helloitsliam.com/2021/10/18/sending-emails-using-microsoft-graph-powershell/ For more advance parameter of the Send-MgUserMail, check this https://www.powershellcenter.com/2022/09/01/send-mgusermail/15KViews1like1CommentRe: Rename folders based on a column in a CSV file using PowerSehll
VidRocksKay You can use this code to fix it $csv=Import-Csv -Path C:\boot\Book3.csv Foreach ($Name in $csv){ try { $Filter=$Name.SamAccount.Replace('.','') +'*' Get-ChildItem -Directory -Path C:\boot -Filter $Filter | Rename-Item -NewName $name.SamAccount } catch { $_.Exception.Message } } replace the Path and you are good to go3.9KViews1like1CommentRe: Add a line to skip or continue loop execution
Audi86 Do{ $Confirmation = Read-Host -Prompt "Are you sure (y/n)?" if ($Confirmation -like "y"){write-host "The user says Yes" -ForegroundColor Green} if ($Confirmation -like "n"){write-host "The user says No" -ForegroundColor red;Return} } while ($Confirmation -ne "y") Write-Host "The Other code"4KViews1like0CommentsRe: PowerShell Remote session getting disconnected with below error in every 150sec to 180 sec.
MMM, If its working fine with other, I suspect it might be the Antivirus or firewall forcing the connection to close. Also you can enable PowerShell logging for more insight https://adamtheautomator.com/powershell-logging-2/ One of the things I might consider is using Wireshark to see more details about how to connection is ended and whats the details.4.4KViews0likes0CommentsRe: Should I delete Windows Terminal or Administrator: Powershell?
Assuming you have a admin permission on the computer, Should be yes, but make sure you have an admin access to the computer. Also where is your antivirus There are some basic practices you can apply to limit PowerShell https://www.calcomsoftware.com/basic-steps-for-powershell-attacks-prevention/ and based on what you said, I understand that you are using a standalone laptop that is not connected to a network7.8KViews0likes0CommentsRe: Find all the AzureADUsers created after a certain date via PowerShell Graph
fstorer Why the quote around the $Date ?? remove them and you are good. $UsersCreatedDate | Where-Object {($_.CreatedDateTime -gt $Date)} Also don't forget to include the all the required property in the Get-MgUser Get-MgUser -UserId $_.Id -Property CreatedDateTime,JobTitle,UserPrincipalName,id15KViews0likes6CommentsRe: Get-Acl | Group Names and Permissions
You need to use the PSCustomObject Build your object with the property needed properties and assign the script output to the object. A basic example here https://community.spiceworks.com/topic/2321720-trying-to-write-a-ps-script-to-output-acl-of-folders Another a bit complex example https://github.com/farismalaeb/Powershell/blob/master/Get-SharePermission/Test-ShareList.ps13.2KViews0likes1Comment
Recent Blog Articles
No content to show