Hi @SakeriyeMohamud-4520
Please follow below steps to run a pester script.
Step 1: Install-Module-Name Pester -Force -SkipPublisherCheck
Step 2: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Step 3: Save the script as Ps1 file and execute
Step 4: Execute the ps1 file
PS C:\WINDOWS\system32> Invoke-Pester C:\Users\ravi2_000\OneDrive\Desktop\tt.ps1
Starting discovery in 1 files.
cmdlet tt.ps1 at command pipeline position 1
Supply values for the following parameters:
Regex: 96e0b105-f56d-4146-8852-31f946b3a620
Discovery found 1 tests in 2.23s.
Running tests.
[+] C:\Users\ravi2_000\OneDrive\Desktop\tt.ps1 2.39s (5ms|155ms)
Tests completed in 2.41s
Tests Passed: 1, Failed: 0, Skipped: 0 NotRun: 0
Use method option to capture the result of execution and try using the captured value in end statement to repeat the function.
Param (
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]
$Regex,
[Parameter(
Mandatory = $False,
ValueFromPipeline = $True,
ValueFromPipelineByPropertyName = $True)]
[Alias("LN")]
[bool] $val)
Begin{
Describe "Check Parameter" {
It "GUID is Vailed" {
$val = $Regex | should -Match "^[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}$"
}
}
}
Process{
}
End{
$val
If ($val -eq 'true')
{Write-Host = "Files copied from user account: " $UserAccount}
}
Here is a helpful page with information about Windows PowerShell
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/powershell
-----------------
--If the reply is helpful, please Upvote and Accept as answer.--