 Hello, folks! It's a pleasure to be here speaking at the Upser Summit and talk about PowerShell. A little about me. My name is, okay, come on, come on, okay. My name is Rodrigo Crespe. I'm from Brazil and I have been working with database since the last decade of the last century. And since 2010, I have been using PowerShell as a way to automate a sort of system process. After Microsoft opened PowerShell Core, which is open source, it became most productive, of course. As I can put it in almost any environment. And I will leave here. And I will leave here, oh, let me laser point. I will leave here my link to my blog. There you will find my contacts. Feel free if you want to exchange messages about process automation, data ops. I'm glad to hear you. Okay. Let's start presentation. Okay, come on. Just a second, please. Come on. Okay, advantages of the PowerShell. One of the first differences to not see when using PowerShell for the first time is semantic clarity. Okay. Most comments in traditional POSIX shells, such as Bash, are heavily abbreviated and often require memorization. Comments are like AWK, PS, topping, or even less do not communicate what they do in your name. It's not self-describing. But wanting when someone already know that they do, the names start to make sense. Think with me. Once I know what LS is list files, the abbreviation makes sense. In PowerShell, on the other hand, commands are perfectly self-describing. They achieve this by following a strict name conventions. It's important. It provides better semantic clarity. It's object-oriented. It's another advantage. And it's possible to use all conventions like inherent polymorphism, etc. Or there are modules available. There are a lot of modules today. But on the market, there are some modules. Some paid, some free. For example, if you were managing a POSIX SQL, there are some modules, but the most expressive is paid. For my SQL, by other hand, is the most expressive is free. It's a convention of the market. You could create some module and put some value or make free. The .NET Core is perhaps the great trigger that allows the great freedom of the use PowerShell. Since we can import and use all frameworks, native class, and once we create it, where you can put .NET Core, you can put PowerShell like an IoT device, Apple machines, or a lot of Linux distributions, and of course Microsoft machines. Microsoft is as old. And like this, the modules create a big advantage. As I said before, there are a lot of modules. But in this example, I can use modules to manage several clouds. I bring here three most relevant in my environment, which I work. We have a modules for Microsoft Azure, Amazon AWS, and Google Cloud. There are probably modules for other cloud players, but I don't know. It's just a search about this. And I will just some example. A few months ago, I had to automate a process that backup virtual machines on-premises and bare metal and make a copy in Azure Blob. And another in a blob in AWS. In AWS, I would restore one VM. And finally, I come back to Azure, and I would restore one Postgrease database that was inside of VM, like a service. It's amazing. Just one script for all. This flexible is essential for automation. Think that some virtual machines were Linux and other Windows. Amazing. I will give you an example in the browser here. I put all the links in the PowerPoint. Here, I search in PowerShellGallery, PowerShellGallery.com, and search for AWS. And you find a publisher, AWS. There are a description for its official here, author. Okay. And here, a description has you can install this module. Here, in action details, you have a file list. Okay. Some DLLs, it's a lib. It's work in Linux. It's work in Mac or Windows. Okay. And here, some describe the AWS tools for PowerShell. Developers and administrators. AWS serves from PowerShell scripting environment. Okay. It's like a goat. And you can find some other publisher or in GitHub and put here PowerShell and AWS. And you can find something. Amazon PowerShell. Okay. I'll get to hub. Here, you find it's not official publisher, but you can try test. There are a free code, you know. Okay. Let me explain about... Ah, it's important. Let me explain. Okay. Let me say multi-virtualization. As well as multi-cloud, it's possible to use several virtualizer modules. These are the ones I use the most. Again, this must be some module for virtualizer I need. In my demos, I show how to search and install. Look here. You have a module for Hyper-V, of course, VMware and Citrix. It's great. You can find here another example. I search in PowerShell Gallery for VMware. And I search the official module for VMware. And you can manage some products inside VMware. You can find here for VMware here. VMware, a lot of modules that use PIN automation. Here, you will find ImageBuilder PowerClean. It's most famous with a lot of PowerClean. And you can use it for your automation. I'll talk about the modules several times in these minutes. But it's important to understand how the commands work in PowerShell. Before all commands inside PowerShell, we call commandlets. It's 9% of PowerShell, the rest it spreads. All commandlets in PowerShell start with a verb and have a separator, of course. And I know, like this example, get chardite or get items inside of a set of data set. The commandlet takes all items from a subset, not necessarily from a directory, as all the people know. In the case of connections to a database, we can list all databases using get chardite. Or in case of Microsoft TV directory, you can list all GPOs using get chardite. It's very logical every command has a parameter and arguments. And you have a parameter and arguments, like this example here. And these syntax, I will get all items in this subset, like a root of Windows machine. And I will list all directories inside. And pipelines are the same as the other script languages, like a bash. It serves to get result set and throw to the next command. In the case of this example, like this, I have a pipe signal and a commandlet and arcs. In this example, I get all items inside the root directory, throw to the commandlet format table. That's format in table format. Same, you return just a name and size of these files. I could here chain more commands as a next other pipe and export to a file. Or I write directly in the table database or export to Excel file or JSON file, just put in a pipe after. A few years ago, I read a documentation that says you can chain up to 256 commandlets. I didn't find this doc anymore. I also think that chain 256 commandlets may be illogical or hard to debug this code. But this information is for knowledge only, I believe. Most modules create connections, like a bridge that code driver use internal provider. For example, when you're going to maintain a SQL server on a Linux or Windows, you can access a unit mounted inside to the PowerShell called SQL server, as well as the file system or system and user variables. How's this that seems abstract to know? I will demonstrate later. About variables, it's important to know that when created a variable without type, it will be treated as an object. Even if you later, it receives integer value, for example, it belong to a class object with integer value. It's important. And as PowerShell is based to a dotnet framework, it's important to know we can and should type data. This will be typed with this available in dotnet framework. These will include array or list. Well, we can do a holy data structure course with PowerShell, right? But moving to provider, it's important. Provider and driver were just as simplified how it works. Remember that drivers mounted in PowerShell, not OS. Here, you can see in the first picture, I use get ps provider to list all providers I have in my machine. Here, you can see provider named file system and this other picture shows my ps drive. It's all drives mounted in my PowerShell. When I see a root and it's important because here my provider, when I have a provider, Microsoft dot PowerShell dot core slash file system, it's a path of my class in dotnet framework. And here you can see some information about the type exposed by this provider. When you can see fire our instances of system dot jl dot file system class in, of course, PowerShell dot net core. I send you this text and have all these links for you search after. And about modules, a little deeper in modules. I can say that they are a set of functions, commands, providers in many structures that you facilitate to use an automation of lines. Include system libs like a dll or libs create in dotnet core. If you're curious about this, searching my blog, you find a post with a video. Let I show how to create a class in sharp and imported in your dotnet core in, sorry, in your PowerShell and use all the functions that are in this class using, of course, links. I use a macOS. Okay. It's works in a head hat or or boom to or Susie. Every links that you use are that not dotnet core. It's works in practice. This means you can if you are a developer or develop a device, it's possible to create a module for customer to manage or even for the partners to deploy. Like you are developer for ERP, you know, software management. You can create a module that create when you run, you have some procedures that create a database, create a open ports in viral, make connections, create users and so on. It's possible. Okay. Let me show in demonstration. It's how it's work here. Here I have a boom to when I have installed a VS code and my demo or in VS code. Okay. And let me explain how you get help, get help, of course. And I try the item. How do you need to know here? And you are flying a help. Okay. And if you need some example, like get help, get PS provide any of the examples. Of course, you have our name example. And they find some example to not have example here. Okay. Oh, new Python. It's another commandlet. Let's go. Okay. No example. Oh, you know, it's possible. There are online. Oh, no. Okay. Well, I, I suggest you explore that. Not like me. Of course. Another example. Get shared item path TMP directory. Okay. Here. A list of my temporary files. Right. And I can use this in my Mac OS like this. Okay. Get, get. Your item. Here. It's working my Mac OS or my Ubuntu. Of course, believe me, it's working Windows machine. Using pipe. Look this. Get the item. Did my temporary far directory. And I use select object to show me name, root, creation time in less for a time. Okay. Rodrigo, there are a problem. When I use get shared item here, they show me units mode, user group, less for a time size, a name. How would we find a creation time? For example, stay tuned. I show you. Okay. Let me explain here. Okay. I'm see here. Just the name. Just the name. No, it's the other. Just the name, root, creation time, less for a time. Okay. Easy. And here I true to this result set to format table. And format table, outsize and hide the table headers. I don't know why, but I need this. Okay. Whoa. Nice. Okay. It's important when you make some automation. I need to verify what operational system I use. Okay. And I can test this using is Linux. True is Mac OS. False is Windows. False. But it's core CLR. True. Because I using common language runtime of core.net core is not Windows. CLR. Okay. If I use here, sorry, is Mac OS true is Linux false is core CLR true. Okay. Right. Guys. Remember that I said the PS drive here. I need to know all drive mounted in my portion environment like this. Get PS drive here. I have a file system, alias, environment, functions, temporary and variables. Okay. But I need to make some filter that I need to know PS drive about variable. Get PS drive or object. It's another command that important where object when I pass. I need to know PS item test this object return name equal a variable. And voila, we have a filter or get child the item variable here. And you can see all items in my variables created. It's a system or user. For example, X is user. W8Z. It's for user here. New variable. I create here. Oh, already fixed. Okay. Okay. We'll create here. I create a variable and I set a value and I read the content. All right. And simple way just remove variable and remove variable. Okay. Here. Here. And just create here. We've setting a value and to read, of course, just like a bash. And I could create here. I could create here a type that variable using integer here. And if I want to see the date type, it's a public serial integer 32 and system value type. Oh, my example is 30. If I need to know this here and get type, get type, it's an integer. Okay. And creating a rate. It's easy. A equal one, two, three, four and count four. Or I can use a equal four dot dot a four, five, six, seven, eight. Or I can create a server at the ADVN SQL one, SQL two. Of course, I think about automation or type array computators, which I have a three positions. And the first positions is surface book. Look this. What's awesome. We can put MacBook Pro computers of book. What's wrong? What's not resizing? Because I have a math. These are my maths. Remember get child the item. When I, I invented less right time. It's here. Get child the item. Get member. Here. All members I can use. I want to use attributes, unique states, PS path, how everything here, what I'll show you. It's all the base to use a PowerShell. And here. Okay. I just throw this away. But you can get this PS one, this file to try in your environment. Okay. Here I have a collection array with PS, a PC one, C two server one. And you can search every your environments. Let me show a hash table. When create a service Doris, when I have a AD server, this EP and SQL server with this IP. Okay. It's easy to create a hash table. You can add, remove easily. And you can serializable a password to access image all of these computers in your network. Let me explain about how propose here. I create this variable X equal. When I put ads before I create some function, some expression here and equal a label and equal my function. My function is PS item. It's that was before some commandlets before the pipeline. When I divide by one megabyte like this. Okay. Hmm. When I apply this, it's easy. X dot E equal than megabytes. X is equal in kilobytes. It's cool, right? Because you can use this get char the item here inside directory. And when I select the name and the size of these files. Oh, I do not have these. Okay. TMP. It's a better example here. Okay. Because I created this. Like a label, I can put here size and divide for megabytes. No megabytes, of course. Okay. But I believe you can understand this. Right. Guys, I just need there are a lot of examples here. You or find this awesome. But how can I use a class system dot net DNS? This is a dot net framework class. When I get a hostname and find my hostname like this. You be sick. Oh, and how I can find modules. These modules are imported in my computer. Okay. These modules are available for use. My computer. And how can I find something like I need to find a module for AWS. Of course, you can go to the website download install, but you can find here. Just find in your PS gallery, all the tools AWS tools. Okay. And you can install this. I do not stop here because my network is not good to do this, but you can install module and update and so on. Okay. Okay. And you can find some command here. Like this. Get command. Oops. Command module. Oh, let me think about. Easy. All the commands in Azure module are listed here. It's to it's not too fast. My network is not good here. Okay. And you can find a lot of examples like how to remove some old files and how to execute to access as age or get top in a file or a grid view and this. Guys, it's I have brought to talk to you. I believe if you like, please let me know if you don't like, let me know. It's important for me. Thank you for attention. I hope you enjoy this session. See you.