This PowerShell script automates the creation of a Certificate Signing Request (CSR) for computers within domain Corporation's IT department. The script prompts for the computer's name, sets various organizational parameters, and generates a CSR file with specified cryptographic properties.
- PowerShell 5.1 or higher
- Administrative privileges (may be required depending on the system's configuration and execution policy)
-
Open PowerShell:
- Right-click on PowerShell and select "Run as Administrator" if administrative privileges are required.
-
Execute the Script:
- Navigate to the folder containing the script and run it by typing:
Replace
.\CSR.ps1
scriptName.ps1
with the actual script filename.
- Navigate to the folder containing the script and run it by typing:
-
Provide Computer Name:
- When prompted, enter the name of the computer for which you are generating the CSR. If no name is provided, the script will use the name stored in the
COMPUTERNAME
environment variable.
- When prompted, enter the name of the computer for which you are generating the CSR. If no name is provided, the script will use the name stored in the
-
Computer Name:
- Prompts the user for the computer's name or retrieves it from the environment variable if not provided.
-
Variable Definition:
- Sets variables for the organization, organizational unit, location, and DNS name.
-
CSR File Content Creation:
- Constructs the contents of the INF file required to generate the CSR, incorporating the previously set variables.
-
File Saving:
- Saves the INF content to a temporary file on the system.
-
CSR Generation:
- Uses the
certreq
command to generate the CSR, saving it to the user's desktop.
- Uses the
-
Completion Notification:
- Informs the user that the CSR has been generated and provides the file path.
The script generates a CSR file named domain_CSR.csr
and saves it to the desktop. This file is then used to request a certificate from a Certificate Authority (CA).
To adapt the script for different organizational units or domains, modify the variable definitions ($organization
, $organizationalUnit
, etc.) at the beginning of the script.
For any issues or questions regarding the script, please contact your IT department or the script maintainer.
This PowerShell script automates the process of importing a .p7b
certificate file into the Local Machine's Personal store on a Windows system. It provides a graphical interface to select the certificate file, eliminating the need for manual file path entry.
- Windows PowerShell 5.1 or higher
- Administrative privileges (to import certificates into the Local Machine store)
-
Run PowerShell as Administrator:
- Right-click on PowerShell and select "Run as Administrator" to ensure the script has the necessary permissions.
-
Execute the Script:
- Navigate to the directory containing the script and run it by typing:
.\import.ps1
- Navigate to the directory containing the script and run it by typing:
-
Select the Certificate File:
- A Windows Explorer dialog will appear. Navigate to and select the
.p7b
certificate file you wish to import.
- A Windows Explorer dialog will appear. Navigate to and select the
-
Import Confirmation:
- After selecting the file, the script will import the certificate and confirm successful importation or display an error message if the import fails.
-
File Selection Dialog:
- Opens a dialog box for the user to select the
.p7b
certificate file.
- Opens a dialog box for the user to select the
-
Certificate Import:
- Imports the selected
.p7b
certificate into the Local Machine's Personal certificate store.
- Imports the selected
-
Error Handling:
- Provides feedback if any errors occur during the import process.
The script will confirm the successful import of the certificate into the specified store or notify the user of any issues encountered during the process.
To modify the script for different certificate types or store locations, you can adjust the filter in the Get-CertificateFile
function or the $certStoreLocation
variable.
For issues or questions related to this script, please refer to your IT department or the script maintainer.