Skip to main content
TopMiniSite

TopMiniSite

  • How to Connect to And Populate Sql Database Using Powershell? preview
    5 min read
    To connect to and populate a SQL database using PowerShell, you can use the SqlClient class available in the System.Data.SqlClient namespace. Start by creating a SqlConnection object and specifying the connection string to your SQL database. Open the connection using the Open method.After establishing the connection, you can use SqlCommand objects to execute queries against the database.

  • How to Use Variable In Sql From Powershell Script? preview
    6 min read
    In PowerShell, you can use variables in SQL queries by creating a connection to a database using ADO.NET and then executing SQL commands with the variables embedded in the query string. You can define the variables in your PowerShell script and then pass them into the SQL query using the Parameters.AddWithValue() method. This allows you to dynamically insert values into your SQL queries based on the variables you have defined in your PowerShell script.

  • How to Parse Json Response In Powershell? preview
    6 min read
    To parse a JSON response in PowerShell, you can use the ConvertFrom-Json cmdlet.After making a request to an API and receiving a JSON response, you can store the response in a variable and then use ConvertFrom-Json to convert the JSON string into a PowerShell object that you can work with.

  • How to Associate A File Type With A Powershell Script? preview
    5 min read
    To associate a file type with a PowerShell script, you can use the assoc and ftype commands in the Command Prompt.First, open Command Prompt as an administrator.Next, use the assoc command to associate the file extension with a file type. For example, to associate .txt files with a custom file type called "MyScript", you would run the command assoc .txt=MyScript.Then, use the ftype command to associate the file type with the PowerShell script.

  • How to Move Files From Specific Folders Only Using Powershell? preview
    4 min read
    To move files from specific folders using PowerShell, you can use the Move-Item cmdlet along with the -Path parameter to specify the source folder and the -Destination parameter to specify the destination folder. You can also use the -Recurse parameter to include subdirectories.

  • How to Return an Object In Powershell? preview
    4 min read
    In PowerShell, you can return an object by using the return keyword followed by the object you want to return. This object can be a string, integer, array, or any other data type that you want to return from a function or script.For example, if you have a function that calculates the square of a number and you want to return the square value, you can use the return keyword to specify the return value.

  • How to Send A Colored Excel to Outlook Email Using Powershell? preview
    3 min read
    To send a colored Excel file to an Outlook email using PowerShell, you can use the "Send-MailMessage" cmdlet to attach the Excel file to the email. However, keep in mind that the color formatting of the Excel file itself will not be visible in the email body. The recipient will need to download the attached file to see the colors.You can use the following PowerShell script to send the colored Excel file as an attachment: $smtpServer = "smtp.office365.

  • How to Use Delegates Inside A Static Powershell Class? preview
    3 min read
    To use delegates inside a static PowerShell class, you first need to define the delegate type using the delegate keyword. Then, within the class, you can declare a field of the delegate type and assign a method to it. Static classes in PowerShell do not allow instance members, so you will need to use static members to work with delegates. You can then invoke the delegate by calling the method it is pointing to.

  • How to Sort By Column In Powershell? preview
    4 min read
    To sort by a specific column in PowerShell, you can use the Sort-Object cmdlet followed by the property name of the column you want to sort by. For example, if you have a CSV file with columns labeled "Name" and "Age", you can sort by the "Age" column by using the command Sort-Object -Property Age. This will reorder the items in the output based on the values in the "Age" column.

  • How to Set A Variables In Powershell? preview
    4 min read
    In PowerShell, you can set a variable by using the syntax $variableName = value. For example, to set a variable named $number to the value 5, you would write $number = 5. You can then use this variable in your PowerShell scripts by referencing its name. Variables in PowerShell are not strongly typed, meaning you do not need to declare the data type of the variable when setting it.

  • How to Change Cursor Position In Powershell Console? preview
    3 min read
    To change the cursor position in a PowerShell console, you can use the Set-ConsoleCursor cmdlet. This cmdlet allows you to set the cursor position to a specific column and row on the console screen.To change the cursor position, you need to specify the column and row where you want the cursor to be placed. For example, to move the cursor to column 10, row 5, you can use the following command:Set-ConsoleCursor 10 5This will move the cursor to the specified position on the console screen.