Getting started with PowerShell for Azure

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in today's show we're going to install the windows Powershell commands for Azure get you connected to Azure and then show you a couple of my favorite scripts but first our intro hello my name is Shane Young with bold zebras those guys right there apparently some people that's the highlight of the show is when I pointed that what do you do anyway in today's show we're going to dive into the Azure Powershell command LS there's like 1100 of them or 2100 of them or a million of them I don't know there's a bunch we're going to look at how to get uh your windows Powershell session configured so that you can connect to Azure get logged into your account and then start to manipulate your VMS using Powershell so should be a pretty fun show the other thing is is I've done this video eight times now because I keep having hardware issues as you can see I've got a new mic um I've installed some new stuff on the PC so cross your fingers that you guys actually get to see episode number eight because I keep trying and hoping to get one to work all right so let's just jump right in okay so here we are on the desktop of a Windows 10 professional uh VM that I made so I'm using the 90-day trial I installed it on hyperv so that way hopefully it doesn't make Camtasia mad when we're doing the recording all right so the first thing you need to do is you need to hit start and then you want to just type in power and then you get the windows po shell you need to right click on that guy you need to run as administrator because what we're going to do is install the modules and in order to install modules and change the execution policy like we're going to do you have to be administrator so the very first thing we're going to do here is we're going to do a start transcript and if you're not familiar with that commandlet remember that just gives us a running command or running list of everything we've done so that way if you do anything bad and you want to go back and look at it you've got a nice history file there it's you can see the path and all that so should be good for that okay the next thing I want you to do is I want you to type in get execution policy remember to use your tab complete and you can see that mine is currently set to restricted depending on your environment yours is might be different settings but restricted is what Windows 10 is by default and so that will not work for installing the Azure Powershell commands unfortunately so what you're going to need to do you're actually going to need to do a set execution policy and then you're going to set that to remote signs type in remote you hit tab complete for that and press enter and it's like hey changing that's really scary are you sure you want to well I say yes so type in y and hit enter and remember anything you find on the internet it's true so it must be safe all right so then I'm do is I'm going do a CLS right clear the screen off so that way we're back to the top and what we need to do first here is we're going to type in install module tap complete and then Azure RM and head dinner so what this is going to do is this is going to go out to the internet in the online gallery and it's going to pull down the Azure um resource manager Powershell commandlets for you install them it's like hey do you really want to pull this stuff off the internet are you sure about that yes because Shane says so so we'll say yes so now this is going to start pulling those down get them on my local machine and expand them out and do all the heavy lifting for getting these set up for me um what you might see that when you guys run this install module is if it's the first time you've retrieved one from the internet it'll install the first time something called in you get so if you get a prompt for that also just go ahead and type why for that so that's just the uh little installer it kind of lets them do things faster you can also see that that installed pretty fast for me it's because I've previously downloaded them I can tell you that normally it takes anywhere about two to five minutes when I put this on a new machine okay so the next thing I want you to do is then type in install module and this time just the word Azure then press enter and actually you know what I don't want to do that I'm going hit no and so we're going to do it again and what I want you to do is I actually want you to do allow clobber so install module Azure dallow clobber and hit enter and so what's going to happen here is it's going to warn us again about the repository so yes again uh but the reason we did allow clobber is there's a command that that Azure RM and Azure have common and they just they they argue about who can be in charge so you just allow clobber it overwrites it best I can tell it doesn't affect anything it has cause me any issues it just lets me get through the process so uh maybe your mile AG of VAR but it's been good for me so far and so while that's running um you might be wondering why do we have Azure RM commandlets and Azure commandlets well the reason for that is that we have a um Azure RM is the Azure resource manager stuff right that's the new Azure experience that's the new portal right portal. azure.com it's the new uh series of stuff and that's where all of Microsoft's Investments are but if you've been using a for for a long time then you've been using um Azure service manager Azure SM sometimes and so that's uh the classic portal so anything you see inside the portal that says classic or old rusty stuff that's all derived from the Azure classic portal and you need the Azure commandlets to take advantage of those also you may or may not need to install both I go ahead and install both that way I don't have any surprises when I go to do something that uh pieces aren't running and while that's running what we'll do is we'll switch over here and we'll run Internet Explorer so start internet explore but I'm going to go to portal. adder.com I'm going to log in with my account you guys are all going to HDE your eyes so you don't see my password right that's very kind of you and we'll hit enter there and now that I've deleted the 30 seconds it took this to open here is the portal and so over here on the left you can see I have two types of virtual machines so Virtual Machine Classic and so anything you have listed in here and you can see I have one called classic Linux anything you have listed here you'll use the azure po shell command wants to control and then if we hit um Regular virtual machines so here's my SharePoint 2013 farm and you'll see um that anything here you'll use the Azure RM um to do so just kind of keeping that mental break there's other things that are classic and they'll always be labeled classic so you kind of have a hint as to what Powershell command L you might use to work with those okay so let switch back over to Powershell and while this finished running I'll hit pause I'll see you in a second all right and so after another minute or so there it finished up and so now we're at the prompt just where we wanted to be yay prompt so we'll go ahead and type in CLS to clear our screen back off keeps me from getting down there at the bottom you know I don't want the pow shell on my face to get in the way of each other so what in there okay and so now that that's uh done what we might want to do here is we might start with a little get command and then we'll do Dash module tab complete and then Azure RM and hit enter and after a few moments there of waiting you can see they start spewing all the Azure commands out I'm going to hit control C because I don't want to wait on that to finish but it gives you a good indication that yes you got everything successfully installed um so we hit CLS again and what you might do is hit up a couple times there and we'll wrap those in parentheses real quick right this is one of my little tricks and then we do a DOT count and this is how we find out that there's 1,398 Powershell commandlets for the Azure RM stuff and then if we go up here and just change this commandlet to Azure right for the Azure old stuff hit enter there's like 708 of these boom 78 which gives us a grand total of 2,16 woo so you guys got plenty of learning to do and if you're unfamiliar with any of this and you need help learning right there is an intro to Powershell video where I talk about get command get help that type of stuff and how to learn and explore this environment so if that's what you need to do then click on the link right over here and that should take care of that for you all right okay so that's how we found our stuff so that's not what you came here to see so we say CLS and so what I want to do now is I want to type in login asz your RM account and we're going to press enter so this is actually going to give us a nice little prop-up box here that we're going to log into and so all you need to do is put in the um email account and hit sign in because now it's going to go and figure out is that a Microsoft personal account is that a work account is that an Office 365 account and give you the proper sign in experience based on what you have all right then you guys hide your eyes again while I type in my password and hit sign in and so then now this is going to start processing you'll see lots of flickering and then here in a moment we'll see there's all my information hopefully uh you guys aren't stealing my Azure identity because there's my Ed ID and subscription ID I don't even know if it's safe to show you so there they are um but so that now that all that is done we're logged into my Azure subscription and if you have multiple multiple subscriptions you can jump around and change but I just have one and so what I'm going to do now is I'm going to say get Azure RM right all the command start with that Azure RM VM so there's all my VMS and we'll just go ahead and hit control C because what it's doing is it's dumping all the objects all the information that's too much info for me and so instead what I'm going to do is I'm going to then pipe that over to um a select statement and say select just name and so there you go you can see I have three VMS dc1 sp1 SQL one and those are the three we just looked at over in the Azure portal so we know that there are sitting there in a stopped deallocated State and remember deallocated means that they're not consuming uh comput so I'm not paying for CPU and RAM but they also don't have an IP address or any of that assigned to them so it's saving my Azure bill but it is costing me um or you know I am paying for the storage of those but so those are my three servers that actually makes up the SharePoint 2013 environment that I do a lot of these demo videos on and so I turn them off and on a lot to try and keep my Azure bill as low as possible so what I've got for you here I'm going to paste it in instead of typing it because you don't want to watch me type this much we hit CLS first and we'll right click to paste so get Azure RM VMS from the resource Group proper 2013 so that's my Resource Group where uh my VMS run and I've talked about resource groups in this video if you don't know anything about resource groups and then I'm going say for each one of those objects over there start AZ your VM name is that object's name and then Resource Group name is the resource Group and then I can hit enter and so then what this is going to do we go ahead and hit enter this is going to go out to Azure now and start each of those VMS for me so it's going to go out fire them up allocate new resources to them which turns on my billing right and then fire each VM up one at a time um so this will take a moment or two so so we'll pause while that runs but uh this is just a really handy script for me to use because I like to be able to come in in the morning fire all my VMS up and then as I work through the day do my stuff and at the end of the day and after these all finished I'll show you the stop VM script that allows you to quickly jump to a better setup I'll hit pause now and I'll see you in five or so minutes when these are done okay okay so that took me about 10 minutes to get those 3 VMS started instead of watching cat videos though I actually started editing the previous part of the recording right get rid of those ums and the little screw-ups I made because you don't want to see those all right uh one of the things to kind of keep note with though when you're running and starting these in this automated fashion is essentially it goes and grabs the first one and it goes out it starts it and it just lets that process run and it doesn't return to the Powershell prompt until it finishes so like if you hit Rand the script and you immediately try and hit control C nothing's going to happen until it finishes working through that first VM so that can be a little annoying sometimes a little offputting um but it's just because it can't really stop the process of starting over an Azure it just has to wait on that process to get done so just keep that in mind control C doesn't work very well for stopping mid starting of a VM but it does work you know if you hit control c one the first vm's processing once it's done it won't process the second third etc etc so little things like that just kind of figure out along the way and if we switch over here to my Azure portal again and you can see now that all my VMS are in the running state so now they've had IP addresses allocated they're ready to go so now I can go do my SharePoint 2013 work for the day and then once the day is over right it becomes 5:30 or the case of Fridays it becomes like 2:00 in the afternoon whatever it might be for you you can run this particular script so I'll grab this one and paste it over here and so here you can see it is get Azure RM vm- Resource Group 2013 right so get all the VM Resource Group same thing as before and then for each one do a stop get the name what resource groups it from and you have to do a confirm false Force you have to kind of do all this to make sure that it uh stops everything for you so I'll hit enter if you don't then you'll have to kind of agree to stop each one and deallocate the resources right because this particular script will deallocate the IPS and all that so it saves me on my compute charges but I do have to worry about you know reconfiguring things the next day um if you don't want to do that there is a parameter uh for the Stop aure um VM commandlet or a R MVM that will avoid uh that issue so you do have that option also okay and so while all this runs I'm not going to go watch cap videos instead what I'm going to do is hit start and take advantage of one of the best features of Powershell right so power so we can run another window right run as administrator now because I started a new one what I want to do is start my transcript again so hit enter so that way I've got an output of everything happens here and so now what I want you guys to do is to kind of switch gears and think okay what about those classic VMS glad you asked and so the first thing you need to work with those classic VMS is we're going to do add Azure account so it's not login like the other in this particular one it's add Azure account so then here you can see it's going to pop up that same interface again so we'll put in my username again and I'll hit sign in because now it's going to go check it's going to be like oh this is a personal account not a uh work account so I'll send him to that environment to log in so there you go you guys will close your when I type in my password and then I'll hit sign in and then we'll get the same Blinky Blinky as it kind of does the credential passing around and then boom there is myh subscription I'm logged in and so then what I can do here is I'm going to do um just a good old get Azure VM and so this is going to do the same thing as um our or get Azure rvm except it's only going to get the classic ones right and so the classic one is still stopped and deallocated and so if I wanted to start those or start well in this case just the one I'll grab this script actually we'll do a CLS first just to get us back to the top of the screen and so we'll do start Azure vm- service name video demo classic VM so service name is what they used to call resource groups or the it's earlier big brother I guess and so you'll need to know what your service name is um and then you're going to do das name and star there so hit enter if you don't know your service name over here in the portal right I could have went to my classic VMS and if we open her up probably all kinds of confused since it's starting right now and so now that loaded you can see there's a video demo classic VMS or we could switch back over here and what I could have done also because we're trying to learn how to do things in Powershell right could have done get Azure service and then you would have seen that the service name is video demo classic VM so but that gets it there so my VM um the start operation succeeded so the classic VM is spun up and just because I'm a nice guy if you need to stop all of them we'll grab this script we'll type in CLS one more time and so there's what the the stop script looks like stop Azure VM service name video demo classic VMS Dame star- Force right and so the with the old ones it's kind of fun because you can just do a name and use the Star Command parameter right whereas in the uh Azure resource manager stuff we do it a more traditional fashion and that we get the list of all the VMS and then we pipe it over to the stop command and we just use it for each object so um slight difference but same result at the end of the day all right I think that's enough for one day right so we've talked about uh getting the Azure commands installed how to start VMS how to stop VMS regardless of what um particular one you're in so hopefully you enjoyed the video if you did hit the old subscribe button here right I like subscribers they keep me motivated and you can always if you need any help hit me up by leaving a comment or hit me on Twitter shanes Cals if you need help need some Consulting work wink wink right there bald zebras I'm always looking for uh hang out with you guys on a professional basis as well so anyway thanks and have a great day
Info
Channel: Shane Young
Views: 73,865
Rating: undefined out of 5
Keywords: Azure, PowerShell, PowerShell for Azure, Azure PowerShell Cmdlets, AzureRM, Install-module AzureRM, install-module Azure, Azure 3.0, Azure cmdlets, login-azurermaccount, add-azureaccount, Bold Zebras, Shane Young, Azure PowerShell Help, Learn Azure PowerShel, Install PowerShell for Azure, powershell basics, powershell tutorial, microsoft azure, microsoft azure tutorial for beginners, microsoft azure tutorial, Windows POwerShell for Azure, install azure powershell cmdlets
Id: 3Q0jG1Doa-s
Channel Id: undefined
Length: 17min 29sec (1049 seconds)
Published: Fri Oct 07 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.