Posts (page 37)
- 7 min readTo compare two folders and add/remove files with PowerShell, you can use the Compare-Object cmdlet. This cmdlet compares two sets of objects and indicates differences. You can use it to compare files in two folders by specifying the folders as the input objects.First, use the Get-ChildItem cmdlet to retrieve the files in each folder and store them in variables.
- 4 min readTo connect MongoDB with PowerShell, you can use the MongoDB PowerShell module. This module provides cmdlets for interacting with a MongoDB database. To connect to MongoDB using PowerShell, you first need to install the MongoDB PowerShell module using the PowerShell Gallery. Once installed, you can use the Connect-MongoDb cmdlet to establish a connection to your MongoDB database by providing the server and database details.
- 6 min readTo enable SQL filestream using Powershell, you can use the following steps:Open Powershell with administrator privileges.Load the SQL Server module by running the command: Import-Module SQLPSConnect to the SQL Server instance by running the command: $server = New-Object Microsoft.SqlServer.Management.Smo.Server("")Set the filestream access level by running the command: $server.Settings.
- 7 min readTo remotely execute a script in PowerShell, you can use the Invoke-Command cmdlet. This cmdlet allows you to run commands on remote computers. First, you need to establish a remote session using the New-PSSession cmdlet and provide the remote computer name. Then, you can use the Invoke-Command cmdlet with the -ScriptBlock parameter to specify the script you want to run remotely. Make sure to include the -Session parameter and provide the session you created earlier.
- 3 min readIn PowerShell, you can step backwards in a path by using the double dot notation. For example, if you are currently in the directory "C:\Users\John\Documents" and you want to move one level up to "C:\Users\John", you can use the command "cd ..". This will take you back one level in the directory structure. You can continue to use ".." to move further up in the directory hierarchy.
- 4 min readIn Powershell, arguments can be passed to a command line by specifying the argument values after the command name. This can be done by separating the command name and argument values with a space. Arguments can be strings, numbers, or flags that modify the behavior of the command.For example, if you have a script named "myscript.ps1" that accepts two arguments, you can run the script and pass the arguments like this: .\myscript.
- 7 min readWhen exporting data to a CSV file in PowerShell, you can separate columns by using a specific delimiter. By default, PowerShell uses a comma (,) as the delimiter when exporting to a CSV file. If you want to use a different delimiter, you can specify it using the -Delimiter parameter when using the Export-CSV cmdlet. For example, if you want to use a tab as the delimiter, you can use the following command: Export-Csv -Path "output.csv" -Delimiter "`t" -NoTypeInformation.
- 3 min readTo extract a value inside a column in a certain pattern in Oracle, you can use the REGEXP_SUBSTR function. This function allows you to extract substrings that match a specified regular expression pattern from a column.For example, if you have a column that contains text data in the following format: "Name: John", and you want to extract the value after the colon, you can use the following SQL query:SELECT REGEXP_SUBSTR(column_name, ':(.
- 5 min readTo connect to a SQL Server database using PowerShell, you can use the Invoke-Sqlcmd cmdlet provided by the SqlServer module. First, you need to import the SqlServer module by running the Import-Module SqlServer command in your PowerShell session. Then, you can use the Invoke-Sqlcmd cmdlet to connect to the SQL Server database by specifying the server name, database name, and your credentials.
- 4 min readMultithreading in PowerShell allows for concurrent execution of multiple threads within a script or command. This can be useful for improving performance by utilizing multiple CPU cores or for handling asynchronous tasks.To perform multithreading in PowerShell, you can use the .NET framework's System.Threading namespace, which provides classes for creating and managing threads. You can use the Start-Job cmdlet to start a new background job, which runs in a separate thread.
- 5 min readTo filter on raw data type in Oracle, you can use the RAWTOHEX function to convert the raw data into a hexadecimal representation. This allows you to perform comparisons and filter the raw data based on specific criteria. For example, you can use the WHERE clause in a SQL query to filter raw data using the RAWTOHEX function to convert the raw data into hexadecimal format. Additionally, you can also use comparison operators such as =, >, <, etc.
- 5 min readTo properly export to CSV using PowerShell, you can use the Export-Csv cmdlet. First, you need to select the data that you want to export using a command such as Get-Process or Get-Service. Then, pipe that data to Export-Csv with the desired file path where you want to save the CSV file. You can also specify additional parameters such as -NoTypeInformation to exclude the type information from the CSV file.