In this recipe, we will discuss the ways we can store the cmdlet data in the repository:
- Import the SqlServer module. This module provides a platform to run and operate system-related cmdlets and stores the output directly in the database objects.
- Define the target instance to the repository.
- Specify the credentials to connect to the SQL instance.
- Convert the plain password text into a SecureString type.
- Build the secured connecting string using the System.Management.Automation.PSCredential assembly.
- Use the pipe to pass the Get-Process cmdlet output as an object to the Write-SqlTableData cmdlet. The following script takes care of the aforementioned tasks.
- Now, save the following content in the DataLoading.PS1 file:
#Import ...