PowerShell ForEach Deep Dive
10:55
Own Your IT Career
8:06
4 ай бұрын
Пікірлер
@tk71
@tk71 Күн бұрын
I answered my own question. $object.PSObject.Copy() actually uses $object.Clone() if the base object is clonable
@jeffbrowntech
@jeffbrowntech Күн бұрын
Nice, thanks for sharing!
@GenePerry
@GenePerry Күн бұрын
Great pace and content, the perfect intro to Graph API - thank you
@Adaption
@Adaption 13 күн бұрын
Clean, concise, and well explained. Thank you, Jeff!
@WayneRoach-v8y
@WayneRoach-v8y 14 күн бұрын
When will you be doing a video on how to get an access token from a client app to connect to MS Graph, without user intervention. (Assuming permissions have been setup already in Azure.)
@jeffbrowntech
@jeffbrowntech 13 күн бұрын
I am not familiar with that process, but I will take it under consideration for a future video.
@nidhinnidhin8764
@nidhinnidhin8764 27 күн бұрын
Very Informative and Helpful Thanks
@marcdoliveira4906
@marcdoliveira4906 Ай бұрын
Outstanding Jeff. Thank you.
@drivetrainerYT
@drivetrainerYT Ай бұрын
And you just demoed that. Happy to be close on one page
@drivetrainerYT
@drivetrainerYT Ай бұрын
Oftentimes I use datetime for output files, plus something like current set page, counter etc, to make filename unique
@jeffbrowntech
@jeffbrowntech Ай бұрын
All great ideas, thanks for sharing.
@drivetrainerYT
@drivetrainerYT Ай бұрын
Thanks again. I just upgraded my simplistic one-block param() approach of stuffing everything between the parentheses into scripting structured self-documented param blocks with validation and custom err messages. You got a docile apprentice here :)
@drivetrainerYT
@drivetrainerYT Ай бұрын
Happy to find this channel. Thank you for the perfect structuring and delivery. Definitely subscribed.
@jeffbrowntech
@jeffbrowntech Ай бұрын
Awesome, thank you!
@chrismast2790
@chrismast2790 Ай бұрын
Why bother putting quotes around the key names in your hash table?
@jeffbrowntech
@jeffbrowntech Ай бұрын
Probably just a habit I picked up at one point for some reason and it's stuck 🤷‍♂️
@ashisharya65
@ashisharya65 Ай бұрын
Great video as usual Jeff. Thanks for making it.
@jeffbrowntech
@jeffbrowntech Ай бұрын
Thanks for watching!
@thearchibaldtuttle
@thearchibaldtuttle Ай бұрын
Great stuff! Thank you for the video!
@jeffbrowntech
@jeffbrowntech Ай бұрын
Glad you liked it!
@markhanna5824
@markhanna5824 2 ай бұрын
Great video - I have an idea for you. Many people have complained to MS that there isn't a bulk method for hiding chats (or leaving, deleting etc). For many of us this becomes a very tedious task. Can PS help? Thanks again!!
@jeffbrowntech
@jeffbrowntech 2 ай бұрын
At a quick glance, that looks like it would take diving into the Teams API to find a user's chats and remove or soft-delete them.
@MalcolManan
@MalcolManan 2 ай бұрын
You've got a like a sub. I have been trying to figure out how to assign permissions to the Managed Identity Service Principal and no useful information is available online. Cheers, keep up and good luck!
@jeffbrowntech
@jeffbrowntech 2 ай бұрын
Glad it helped, and that's why I wrote the article and did the video. Seems like a complicated process and wanted to document it myself.
@samlegend6064
@samlegend6064 3 ай бұрын
What is the future of Microsoft Graph API, and how is Microsoft evolving it? Is investing in learning this skill for career growth a good idea?
@jeffbrowntech
@jeffbrowntech 2 ай бұрын
Learning how to interact with any API is a good thing. Microsoft's Graph API is the gateway to managing all of its services directly. You can write your own code to perform actions or get information. I've used it when there wasn't a clear PowerShell cmdlet or it had limitations that querying the API directly was better.
@fabianzoon1648
@fabianzoon1648 3 ай бұрын
Thank you so much. It answered all of the questions I had. Really nice. tnx.
@jeffbrowntech
@jeffbrowntech 2 ай бұрын
Great to hear!
@mattcargile
@mattcargile 3 ай бұрын
Off the jump, it looked like you could just use parameter sets for private. Haven’t finished video though.
@mattcargile
@mattcargile 3 ай бұрын
Oh nvm. It’s a parameter value you are keying on. I would just have a private channel switch maybe or another function. Dynamic param is nice too. I usually forget about it. Hmmm
@mattcargile
@mattcargile 3 ай бұрын
Hmmm. Yeah I see this simplifies UX while complicating for the dev. I think it is a win especially to reduce complexity. It might reduce discoverability in the help. I’m curious if private channel owner would show in the help.
@jeffbrowntech
@jeffbrowntech 3 ай бұрын
For sure, multiple parameters to cover parameter sets, my goal here was to have one parameter for the channel name, channel type, then specify a private channel owner when needed. But definitely multiple ways to accomplish this.
@psjoshooaj
@psjoshooaj 3 ай бұрын
I dig regex for searching through logs or parsing native command output where the formatting isn't quite predictable. I also tend to use it with the "-replace" operator to either remove the text matching a pattern or transform it somehow. One of the most common uses for me though is within Visual Studio Code and doing a regex search, or find & replace, in a file or across all files in the repo. That is super helpful when you need to find a very specific pattern and change it everywhere.
@ashisharya65
@ashisharya65 3 ай бұрын
Thank you so much for making this video 🙏
@jeffbrowntech
@jeffbrowntech 3 ай бұрын
Glad it was helpful!
@jeffbrowntech
@jeffbrowntech 3 ай бұрын
How do you use regex and PowerShell together? Leave a comment below!
@SimonRNorton
@SimonRNorton 3 ай бұрын
Just the introduction I was looking for! Thank you so much!
@jeffbrowntech
@jeffbrowntech 3 ай бұрын
You bet, glad it was helpful!
@FUNKYSASSMANN
@FUNKYSASSMANN 3 ай бұрын
Excellent video and demonstration!
@psjoshooaj
@psjoshooaj 3 ай бұрын
When I need to save some kind of state in a module, I’ll use a script scope variable as well. Typically I’ll explicitly declare that variable in my PSM1 so that there’s one place to go to know all script scope variables used in the module. And I’ll try to minimize the functions that touch the variable directly. Usually by having private get/set functions and ensuring that any other function that needs the variable will get it from the private function rather than accessing it directly. Depending on the circumstances, environment vars can fill a similar role except they’re available in the global scope making them transparently available to the user and any other script/module running in that session.
@jeffbrowntech
@jeffbrowntech 3 ай бұрын
Do you create the variable outside all the functions in your PSM1 file? Did not think of that approach but I like it!
@psjoshooaj
@psjoshooaj 3 ай бұрын
@@jeffbrowntechExactly, not that it makes a _technical_ difference, but I know there is only one place to look to remember if/which script scope variables are being used and it feels more intentional. I also do a lot of C# code and it still feels dirty to declare a variable in an “inner scope” and then access it outside of that “scope” even though those try-block or if-block scopes are imaginary and don’t exist in PowerShell.
@jeffbrowntech
@jeffbrowntech 3 ай бұрын
@@psjoshooaj I agree, I like the idea of having one place where the variable lives, then the get/set functions to control it. Thank you for sharing!
@hassenfepher
@hassenfepher 3 ай бұрын
brand new to graph, and this video is where i started. i tried editing the department, and i got the following error. "code": "Authorization_RequestDenied", "message": "Insufficient privileges to complete the operation.", this was performed with the global admin for my account, and i confirmed i can edit this property in the azure identity portal i can pull these attributes just fine. do i have an application permission limitation in this explorer?
@hassenfepher
@hassenfepher 3 ай бұрын
looks like i needed to add permissions in the permissions tab. i made it work. is there a way to grant these permissions temporarily? if i close the session, will the api permissions persist? should i manually revoke the permissions i just granted at the end of this exercise to reduce the attack surface until i get back into graph?
@jeffbrowntech
@jeffbrowntech 3 ай бұрын
@@hassenfepher I believe those permissions are persistent, if you are unsure of leaving those out there, go ahead and revoke them.
@CoreTheBK
@CoreTheBK 2 ай бұрын
@@hassenfepherI could be wrong but JIT PAM solutions might be what you need for this sort of security you’re mentioning.
@francescosovis7938
@francescosovis7938 3 ай бұрын
Thank you very much. Your instructions on the video are very useful.
@jeffbrowntech
@jeffbrowntech 3 ай бұрын
Glad to hear that!
@psjoshooaj
@psjoshooaj 3 ай бұрын
That was a great tutorial on dynamic parameters! I've used them a couple of times, but I generally avoid them because of the added complexity for me and the reduced discoverability for users. For the example here with public vs private "Teams teams" I'm not sure whether I would come up with a way to use a second parameterset, or have two public commands like "New-PublicChannel" and "New-PrivateChannel" which delegate to a single private function to do the work (to minimize duplicate code). One of the things that holds me back from using dynamic parameters is the lack of platyPS support but if I remember correctly, I think Sean Wheeler mentioned platyPS v1 may have support for dynamic parameters and supposedly they're aiming to release v1 this year so it's definitely worth another look!
@jeffbrowntech
@jeffbrowntech 3 ай бұрын
What do you think about dynamic parameters, is this something you would use?
@Team_vanquishing
@Team_vanquishing 4 ай бұрын
Thanks, Jeff, for sharing your experiences. This is very motivating!
@Team_vanquishing
@Team_vanquishing 4 ай бұрын
Thanks for sharing this information Jeff! Much needed and right on time!
@thearchibaldtuttle
@thearchibaldtuttle 4 ай бұрын
Nice video, thank you!
@justin.emmons
@justin.emmons 4 ай бұрын
This video was excellent Jeff. Light bulbs were going off while watching this. Honestly can't wait to go to work to try some of these!
@jeffbrowntech
@jeffbrowntech 4 ай бұрын
Have you ever used or needed tab completion for your parameters? Leave a comment below!
@ashisharya65
@ashisharya65 4 ай бұрын
Hi Jeff, Please make the next video on Regex in PowerShell.
@jeffbrowntech
@jeffbrowntech 4 ай бұрын
It's a good topic, it's on my to-do list.
@starvosxant4348
@starvosxant4348 4 ай бұрын
This is terrible... Not the video. The video is great! But why this information is not easy to find in Microsoft Docs? They should have a atep by step guide like this... Anyway, thanks for your help! Why did the Graph series stopped?
@jeffbrowntech
@jeffbrowntech 4 ай бұрын
That is primarily why I blogged about it and created the video, to put all the steps together. That's all I had for Graph stuff at the time but will produce more if something comes up. I primarily pull from things I encounter in my daily work.
@starvosxant4348
@starvosxant4348 4 ай бұрын
@@jeffbrowntech could you bring more examples of using Python? The general step: register the app, request the token, use the API via requests/SDK
@jeffbrowntech
@jeffbrowntech 4 ай бұрын
@@starvosxant4348 Unfortunately I don't know Python, PowerShell is my go-to scripting language for now.
@pawelhaubus172
@pawelhaubus172 4 ай бұрын
Great video, when i run 'New-MgServicePrincipalAppRoleAssignment' i get the 'Insufficient privileges to complete the operation.' error, I can't figure out which permissions are missing, i created the function app,, i am also a global admin, but error comes up each time when itry to run it, any idea what m,ay be causing it?
@jeffbrowntech
@jeffbrowntech 4 ай бұрын
Double check what scopes you have in your Microsoft Graph connection context, there should be something like Directory.ReadWrite.All: Get-MgContext | Select-Object -ExpandProperty Scopes
@pawelhaubus172
@pawelhaubus172 4 ай бұрын
@@jeffbrowntech thanks for your replay, I managed to resolve my issue, At first I only used scope which you mentioned in the video 'Connect-MgGraph -Scopes 'Directory.ReadWrite.All'' but it did not work, only after adding 'AppRoleAssignment.ReadWrite.All' it started to work for me, so first command was "'Connect-MgGraph -Scopes 'Directory.ReadWrite.All', 'AppRoleAssignment.ReadWrite.All'" in my case Thanks for the comments!
@jeffbrowntech
@jeffbrowntech 4 ай бұрын
Interesting, thank you for the update, glad you were able to figure it out! I don't believe I needed that permission previously but something could have changed in the requirements.
@andresjordan1906
@andresjordan1906 4 ай бұрын
@@pawelhaubus172 Thank you for posting your solution, I was having the same issue until I came across your comment.
@dengsue
@dengsue 4 ай бұрын
I dont see it on my end, can you help?
@jeffbrowntech
@jeffbrowntech 4 ай бұрын
What specifically don't you see?
@susheel_dogra
@susheel_dogra 5 ай бұрын
You're amazing Jeff
@susheel_dogra
@susheel_dogra 5 ай бұрын
Thank you so much , It helped a lot !!
@jeffbrowntech
@jeffbrowntech 5 ай бұрын
Glad it helped!
@ashisharya65
@ashisharya65 5 ай бұрын
Great video Jeff 👏
@MadiAnas-wc3xt
@MadiAnas-wc3xt 5 ай бұрын
Is this possible via Terraform?
@jeffbrowntech
@jeffbrowntech 5 ай бұрын
I have not personally done that but I can't think of any reason it couldn't be. You would have to know the app role to assign ahead of time. registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/app_role_assignment
@MadiAnas-wc3xt
@MadiAnas-wc3xt 5 ай бұрын
@@jeffbrowntech This worked btw. Thank you! I needed to be Global Administrator not just Application Administrator. Not sure why yet. Need to work on that. ``` data "azuread_application_published_app_ids" "well_known" {} resource "azuread_service_principal" "msgraph" { client_id = data.azuread_application_published_app_ids.well_known.result.MicrosoftGraph use_existing = true } resource "azuread_app_role_assignment" "directory_read_all" { app_role_id = azuread_service_principal.msgraph.app_role_ids["Directory.Read.All"] principal_object_id = azurerm_user_assigned_identity.github.principal_id resource_object_id = azuread_service_principal.msgraph.object_id } ```
@garrettnelson8469
@garrettnelson8469 5 ай бұрын
Another great video Jeff!
@garrettnelson8469
@garrettnelson8469 6 ай бұрын
Great video Jeff! Splatting is such a handy feature.
@leeblack2103
@leeblack2103 6 ай бұрын
Thank you! Please help with JSON imports
@jeffbrowntech
@jeffbrowntech 6 ай бұрын
Check out ConvertFrom-Json learn.microsoft.com/powershell/module/microsoft.powershell.utility/convertfrom-json
@ashisharya65
@ashisharya65 6 ай бұрын
Thanks for making this video Jeff. ✌️
@derekbelanger7839
@derekbelanger7839 6 ай бұрын
Thanks for this! Ternary syntax is the same in Bicep so getting used to it is helpful for that onramp too!
@justin.emmons
@justin.emmons 7 ай бұрын
Great stuff Jeff. I've never messed around with [void] and or Out-Null. I'm still a PS noon so much of the stuff I do is just Ah-Hoc. Is the main reason for Out-Null for performance?
@jeffbrowntech
@jeffbrowntech 7 ай бұрын
This is the StackOverflow thread I referenced in the video: stackoverflow.com/questions/5260125/whats-the-better-cleaner-way-to-ignore-output-in-powershell The way I am using Out-Null seems to be slower but someone points out it may be due to the pipeline. Overall, we're talking milliseconds, but if you're script is long running and doing the operation millions of times, it could make a difference.
@justin.emmons
@justin.emmons 7 ай бұрын
@@jeffbrowntech Thanks Jeff. Keep up the great work you're doing.
@ashisharya65
@ashisharya65 7 ай бұрын
This really keeps me motivated towards my goals, Jeff. 😊 Thank you for making this video 😊 I am also trying to switch to a complete Azure cloud engineer role and I am really working hard towards that goal and hope will get there in the coming months or might be there in a few years 😊
@ashisharya65
@ashisharya65 7 ай бұрын
Great video Jeff. Thanks for making this video. It has clear all my doubts related to Parameter sets. 😊
@ashisharya65
@ashisharya65 7 ай бұрын
Hi Jeff, Thanks for making this video. Please make a video sometime on how to play with Regex with PowerShell.
@jeffbrowntech
@jeffbrowntech 7 ай бұрын
I am no regex expert but will see what I can put together.