Repository navigation
Documentation
Yelodress edited this page Nov 12, 2024
·
5 revisions
If you're facing an issue with special characters in your custom text, consider converting them to UTF-8:
$yourVarName = [System.Text.Encoding]::UTF8.GetString([System.Text.Encoding]::Default.GetBytes("Your text"))You can add a messagebox to warn users from what informations you're going to retrieve. Add this on the top of your script:
Add-Type -AssemblyName PresentationFramework # load the assembly .NET framework (to make the script able to create a message box interface)
$caption = "Title"
$messageBoxText = "Description"
$icon = [System.Windows.MessageBoxImage]::Information
$button = [System.Windows.MessageBoxButton]::OKCancel
$msgbox = [System.Windows.MessageBox]::Show($messageBoxText, $caption, $button, $icon) # Mixing all components
if ($msgbox -eq "OK") {
# User accepted, coninue
}
else {
# User declined, canceling the script
exit
}$stepName = "Your Step"
Show-CustomProgressBar -CurrentStep X -TotalSteps $TotalSteps(do not forget to replace X by your step number)
Replace every X by your total amount of step
$TotalSteps = X
function Show-CustomProgressBar {
param (
[int]$CurrentStep,
[int]$TotalSteps
)
$ProgressWidth = 50
$ProgressBar = [string]::Join('', ('o' * [math]::Round(($CurrentStep / $TotalSteps) * $ProgressWidth)))
Write-Host -NoNewline "`r[$ProgressBar] $([math]::Round(($CurrentStep / $TotalSteps) * X))/X $stepName"
if ($CurrentStep -eq $TotalSteps) {
Write-Host ""
}
}Add this as a new column in $combinedData:
"Specific user" = if (Get-LocalUser -Name "Your username") {"Yes"} else {"No"}"Specific group" = if (Get-LocalGroup -Name "Your group name") {"Yes"} else {"No"}Add this as a new column in $combinedData:
"Specific software" = $appsList | Where-Object { $_.DisplayName -like "* Your software name *" } | Select-Object -ExpandProperty DisplayVersion -First 1Note: You can remove the asterisks if you're sure of your exact app name.