This module has no dependencies.
For full release notes see .\Resources\ReleaseNotes.txt
### 2.2.10
* added Get-AppEventsSound – determines sounds configured for Windows events
* added Get-ConsoleWindowSize – returns both the window size and buffer size of current console window
* added Get-DiskType – returns the type of disk and type of bus for a given computer(s) local disk(s)
* added Get-FileSizeOnDisk – returns actual disk usage when NTFS compression is enabled for file(s)
* added Get-IpV4Network – to determine network given IP address and subnet mask
* added Get-StringHash – to send a string, or array of strings through a hashing function
* added Set-EOLTerminator – to convert a text file to either Unix, Mac, or Windows EOL characters
* added Set-FileEncoding – to set the file encoding on a text file
* added Set-WindowState – to minimize/maximize a window
* added Test-CSVFormat – determine if number of fields match header row
* removed Get-MD5Sum – functionality already present in Get-FileHash available in Microsoft.PowerShell.Utility module
* updated ConvertFrom-Base64 – added $EncodingType to provide support for Ascii, UTF32, etc. encoding
* updated ConvertTo-Base64 – added $EncodingType to provide support for Ascii, UTF32, etc. encoding
* updated Get-CaesarCipher – to allow negative rotation
* updated Get-FileEncoding – allow processing of multiple files, output now shows both encoding and fullname of file
* updated Get-PrivateProfileSection – fixed error when ini value contains a backslash ‘\’
* updated Get-SqlIndexFragmentation – fixed ???
* updated Invoke-Beep – fixed ???
* updated Invoke-SoundPlayer – performed a .Dispose() as part of cleanup
* updated New-InputBoxSecureString – correct equality test to be case sensitive
Please forgive the cross posting between reddit.com/r/PowerShell and here.
I’ve tried specifying -noprofile at the command line and the same erroneous behavior. Below is some sample command output between the different incarnations of PowerShell.
(PSv5) C:\Users> [System.Windows.WindowState]
Unable to find type [System.Windows.WindowState].
At line:1 char:1
+ [System.Windows.WindowState]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Windows.WindowState:TypeName) [], RuntimeException + FullyQualifiedErrorId : TypeNotFound
(PSv7) C:\Users> [System.Windows.WindowState]
InvalidOperation: Unable to find type [System.Windows.WindowState].
(PS_ISEv5) C:\Users> [System.Windows.WindowState]
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True WindowState System.EnumNote how (PS_ISEv5) is the only one providing the expected result.
I’m at a loss as to where to dig deeper to find root cause. My Google-Fu is not providing any insight. Anyone have any breadcrumbs to point me in the right direction?
I tried loading powershell.exe and pwsh.exe with -noprofile and the behavior was the same. I’ve attempted to search on Google and nothing useful was returned.
Hide, Show, Minimize, Maximize, etc window from Powershell.
| { | |
| ( | |
| [()] | |
| [( | |
| )] | |
| [()] | |
| [] | |
| [()] | |
| [] ( –id ).MainWindowHandle | |
| [()] | |
| [] | |
| ) | |
| { | |
| { | |
| } | |
| –memberDefinition | |
| public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); | |
| name namespace Win32Functions –passThru | |
| } | |
| { | |
| ::ShowWindowAsync( []) | |
| ( ) | |
| () | |
| { | |
| } | |
| } | |
| { | |
| } | |
| } | |
| Name Value |
Сообщения: 41
Благодарности: 2
Кому надо используйте)
Готовый powershell gui скрипт, окно которое скрывается при нажатии кнопки свернуть в заголовке окна в трей, уведомляет что оно свернуто, после нажатия на значок в трее разворачивается, что я и хотел).
Правда я хотел ещё что бы была в заголовке окна ещё одна кнопка, но как я понял это невозможно сделать на powershell gui только если писать свою программу, там можно, а тут нельзя ну или я не совсем разобрался. Если знаете как это сделать напишите.
$HideWindow = '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);'
Add-type -Name win -Member $HideWindow -Namespace native
[native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0)
Add-Type -AssemblyName System.Windows.Forms
# Создаем форму
$form = New-Object System.Windows.Forms.Form
$form.Text = "Мое окно"
$form.Size = New-Object System.Drawing.Size(800, 500)
# Добавляем обработчик события изменения размера окна
$form.add_Resize({ if ($form.WindowState -eq "Minimized") { $form.Hide() $notifyIcon.Visible = $true $notifyIcon.ShowBalloonTip(1000) }
})
# Добавляем обработчик изменения состояния окна
$form.add_SizeChanged({ if ($form.WindowState -eq "Minimized") { $form.Hide() $notifyIcon.Visible = $true $notifyIcon.ShowBalloonTip(1000) }
})
# Добавляем обработчик закрытия формы
$form.add_FormClosing({ $form.Hide() $notifyIcon.Visible = $true $_.Cancel = $true
})
$notifyIcon = New-Object System.Windows.Forms.NotifyIcon
$notifyIcon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon((Get-Process -Id $PID).Path)
$notifyIcon.Visible = $false
$notifyIcon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Info
$notifyIcon.BalloonTipText = "Окно свернуто в трей"
$notifyIcon.BalloonTipTitle = "Пример окна PowerShell GUI"
$notifyIcon.ShowBalloonTip(1000)
# Добавляем обработчик клика по значку в трее
$notifyIcon.add_Click({ $form.Show() $form.WindowState = "Normal" $notifyIcon.Visible = $false
})
# Добавляем контекстное меню для значка в трее
$contextMenu = New-Object System.Windows.Forms.ContextMenu
$menuItem = New-Object System.Windows.Forms.MenuItem
$menuItem.Text = "Выход"
$menuItem.add_Click({ $form.Close() $notifyIcon.Dispose()
})
$contextMenu.MenuItems.Add($menuItem)
$notifyIcon.ContextMenu = $contextMenu
# Показываем форму
$form.Show()
[System.Windows.Forms.Application]::Run()PS. Возможно где то ошибки, но вариант рабочий если поправите и скините сюда, будет очень хорошо.
Serguei Kouzmine, реально ли поменять стили такого окошка? Может фон прикрутить или кнопки красивые сделать?
Можно потом после дописанания окончательно конвертировать в ps2exe в .exe и будет своя мини программа), которая делает какое то действие в системе.
Недавно тут спрашивал про тачпад, оригинальная программа урезана в функционале, на win7 была удобнее и настроек больше, можно с win7 настройки программы скопировать из реестра, добавить их в powershell в виде галок, и конвертировать в exe)))
будет некий заменитель оригинальной программы)

Table of contents
- Introduction to PowerShell’s Start-Process Command
- Understanding the Start-Process Command
- Running Programs with PowerShell’s Start-Process Command
- Running Programs with Elevated Privileges using Start-Process Command
- Running executables as a different user with Start-Process in PowerShell
- Running PowerShell Scripts with Start-Process Command
- Using Arguments with Start-Process Command
- Running Executables with Start-Process Command
- Running Batch Files with Start-Process Command
- Common Errors and Troubleshooting Tips with Start-Process Command
- Conclusion and Best Practices
Introduction to PowerShell’s Start-Process Command
The PowerShell Start-Process command is a powerful tool that is used to start a new program or script in a new process. This cmdlet lets us launch external programs directly from the command line or a PowerShell script. You can use it to start any program, including batch files, executables, and PowerShell scripts.
Understanding the Start-Process Command

The PowerShell Start-Process command has a number of different parameters that you can use to customize the way that the command runs. The most important parameter is the FilePath parameter, which specifies the location of the program or script that you want to start.
Another important parameter is the ArgumentList parameter, which allows you to pass arguments to the program or script you are starting. For example, if you are starting a PowerShell script, you can pass in parameters to the script using the ArgumentList parameter.
The Start-Process command also has parameters that let you specify the working directory, window style, and priority of the process you’re starting. These parameters can be useful if you need to start a program or script in a specific way. Along with other default parameters, Here is the list of important parameters of start-process cmdlet:
| Parameter | Description |
|---|---|
| -FilePath | Specify the executable, application, file, batch, or script to run |
| -ArgumentList | Specifies parameters to use with the process to start |
| -Credential | User account to run the process |
| -NoNewWindow | Open a window in the current console process |
| -Passthru | Returns the process object of the process started. You can get the process ID from it. |
| -RedirectStandardError | Specify text file to redirect error output to |
| -RedirectStandardInput | Text file with input for the process |
| -RedirectStandardOutput | Specify text file to redirect output to |
| -UseNewEnvironment | The process will use new environment variables specified for the process instead default, under: Machine and user |
| -WindowStyle | Specifies the state of the window: Normal, Hidden, Minimized, or Maximized |
| -LoadUserProfile | Loads the Windows user profile from the HKEY_USERS registry key for the current user. This does not affect the PowerShell profiles. |
| -Wait | Wait for the process to complete before continuing with the script |
| -WorkingDirectory | The location where the process should start in |
| CommonParameters | Verbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable |
Running Programs with PowerShell’s Start-Process Command
Start-Process -FilePath "notepad.exe"
This command would start Notepad in a new process.

If you want to run an executable in the background without displaying any windows or prompts, you can use the -WindowStyle Hidden parameter of the Start-Process cmdlet. Similarly, you can open any specified file (Non-executable file, such as a doc file) in a new window using:
Start-Process -FilePath "C:\Docs\AppLog.txt" -WindowStyle Maximized
This opens the file “C:\Docs\AppLog.txt” in a maximized window.
PowerShell to Open Files
To open a file in PowerShell, you can use the Start-process (or its alias: Start) command:
Start "C:\Temp\Archive.zip"
This method allows you to open files in the associated programs in PowerShell. In the above case, the zip file will be opened in WinRAR/WinZip/Windows Explorer, depending on your computer’s default program associations.
Open File Explorer from PowerShell
To open Windows File Explorer from PowerShell, Use: Start-Process Explorer
Running Programs with Elevated Privileges using Start-Process Command
Start-Process -FilePath "powershell.exe" -Verb RunAs
Start-Process -FilePath "C:\Temp\Log.txt" -Verb Print
Running executables as a different user with Start-Process in PowerShell
Start-Process -FilePath "powershell.exe" -Credential (Get-Credential)

# Parameters $FilePath = "C:\Scripts\RunMe.bat" $UserName = "Crescent\salaudeen" $Password = "Password goes here" #Prepare the Credentials $SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force $Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword #Start a process with Start-Process -FilePath $FilePath -Wait -Credential $Credential
Running PowerShell Scripts with Start-Process Command
The PowerShell Start-Process command can also be used to start PowerShell scripts. To start a PowerShell script, you need to specify the location of the script using the FilePath parameter. Additionally, you can pass arguments to the script using the ArgumentList parameter.
Start-Process -FilePath "powershell.exe" -ArgumentList "-File C:\Scripts\MyScript.ps1"
This command would start the MyScript.ps1 script in a new PowerShell process.
Using Arguments with Start-Process Command
As mentioned earlier, the PowerShell Start-Process command allows you to pass arguments to the program or script you are starting. This can be useful if you need to customize the behavior of the program or script.
For example, if you are starting a program that requires command-line arguments, you can pass those arguments using the ArgumentList parameter.
Start-Process -FilePath "myprogram.exe" -ArgumentList "-arg1 value1", "-arg2 value2"
This command would start the myprogram.exe program with the arguments “-arg1 value1” and “-arg2 value2”. The parameter values depend on the application you are running. Let’s take an example: Suppose you want to open a URL in Google Chrome. Here’s how you can do it:
Start-Process -FilePath "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -ArgumentList "https://www.google.com" -Wait -WindowStyle Maximized

In this example, the -FilePath parameter specifies the path to the executable file for Chrome and the -ArgumentList parameter provides the URL to open in Chrome. The arguments are passed as a string, where a space separates each argument. It also uses a wait switch to wait for the process to close and Windowstyle parameters. This enables us to provide multiple args to the executable and customize its behavior.
Running Executables with Start-Process Command
Running executables with Start-Process in PowerShell is a straightforward process. By simply specifying the path of the executable as an argument to the Start-Process cmdlet, PowerShell launches the program and executes it. This method is particularly useful when you want to run standalone executables without any additional parameters or customization. Let’s take a look at an example:
To start an executable, you need to specify the location of the executable using the FilePath parameter.
Start-Process -FilePath "C:\MyProgram\MyProgram.exe"
This command would start the MyProgram.exe executable.
Running Batch Files with Start-Process Command
PowerShell is not limited to running standalone executables only; it can also execute scripts and batch files effortlessly. By utilizing the Start-Process cmdlet, we can launch scripts and batch files in PowerShell and automate complex tasks. This provides us with the flexibility to integrate PowerShell with other scripting languages and leverage their capabilities. Let’s take a look at an example of running a PowerShell script using Start-Process:
To start a batch file, you need to specify the location of the batch file using the FilePath parameter.
Start-Process -FilePath "C:\MyBatchFile.bat"
Common Errors and Troubleshooting Tips with Start-Process Command
While the PowerShell Start-Process command is a powerful tool, there are a few common errors that you may encounter.
- Access is denied: One common error is the “Access is denied” error. This error occurs when you try to run a program or script with elevated privileges, but you do not have permission to do so. To fix this error, you will need to log in as an administrator or use the RunAs parameter to run the program with elevated privileges.
- File not found: Another common error is the “File not found” error. This error occurs when you specify an incorrect file path. To fix this error, you will need to double-check the file path and make sure that it is correct. This includes verifying file permissions and network access if the executable resides on a remote machine. Always use the full path of the executable to avoid any ambiguity or reliance on the system’s PATH environment variable.
- Invalid Arguments: If the executable requires specific arguments, ensure that they are passed correctly using the
ArgumentListparameter of theStart-Processcmdlet.
Conclusion and Best Practices
When using the Start-Process command, it is important to double-check your file paths and arguments to avoid common errors. Additionally, it is a good practice to test your commands in a test environment before running them in a production environment.
Now that you have a better understanding of the PowerShell Start-Process command, you can start using it to automate your tasks and streamline your workflow!
How do I run a PowerShell script like an EXE?
How do I run an EXE file in PowerShell?
To run an EXE file in PowerShell, you can use the “Start-Process” cmdlet. Here’s an example of the command you can use: “Start-Process -FilePath 'C:\Path\to\file.exe'“. Replace ‘C:\Path\to\file.exe‘ with the actual path to your EXE file.
How do I install an EXE file in PowerShell silently?
To install an EXE file silently using PowerShell, you can use the Start-Process cmdlet with the -ArgumentList parameter. Here’s an example of the command you can use: Start-Process -FilePath "path\to\file.exe" -ArgumentList "/silent"
How do I open an application in PowerShell?
How to run an exe file from the command line?
To run an EXE file from the command line, you need to navigate to the directory where the file is located using the “cd” command. Once you are in the current directory, you can simply type the name of an executable file and press enter to run it.
How do I run PS from the command prompt?
How can I wait for a process to finish before proceeding?
To make PowerShell wait for a process to finish before continuing, you can use the -Wait parameter with Start-Process. This parameter ensures that PowerShell waits for the process and all its descendants to exit before returning control.
Can I pass arguments to the executable with Start-Process?
Yes, you can pass arguments to the executable using the -ArgumentList parameter. Start-Process -FilePath "notepad.exe" -ArgumentList "C:\Temp\Logs.txt"
Can I capture the output of a process started with Start-Process?
Yes, you can capture the output of a process by using the -RedirectStandardOutput parameter and specifying a file path to store the output. For example:Start-Process -FilePath "ping.exe" -ArgumentList "google.com" -RedirectStandardOutput "output.txt"
This command will start the ping command, ping google.com, and redirect the output to the “output.txt” file.
Can I start a process in a minimized or maximized window?
Yes, you can control the window state of the process using the -WindowStyle parameter. The available options are “Normal”, “Hidden”, “Minimized”, and “Maximized”. For example: Start-Process -FilePath "notepad.exe" -WindowStyle Minimized
Заранее благодарю за вашу помощь.
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$Form = New-Object System.Windows.Forms.Form
$Form.Size = New-Object System.Drawing.Size(460,350)
$Form.Text ="Pass info"
$Form.AutoSize = $false
$Form.MaximizeBox = $false
$Form.MinimizeBox = $true
$Form.BackColor = "#c08888"
$Form.ShowIcon = $true
$Form.SizeGripStyle = [System.Windows.Forms.SizeGripStyle]::Hide
$Form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D
$Form.WindowState = "Normal"
$Form.StartPosition = "CenterScreen"
$Form.Opacity = 1.0
$Form.TopMost = $false
############################################## Function start ##############################################
function Info {
$wks=$InputBox.text;
Write-Host $wks
$regex1 = "[^-a-zA-Z0-9_#.!@]+"
$regex2 = "[^-а-яА-Я0-9_#.!@]+"
If($wks -match $regex2) {
$Result1=Get-ADUser -identity $wks -Properties * | select CN -ExpandProperty CN
$outputBox.text=$Result1
$Result2=Get-ADUser -identity $wks -Properties * | select PasswordLastset -ExpandProperty PasswordLastset
$outputBox2.text=$Result2
}
If($wks -match $regex1) {
$wks2 = "$wks*"
Write-Host $wks2
$Result3=Get-AdUser -Filter 'name -Like $wks2' | Select Name -expandproperty Name| Sort Name | fl | out-string
Write-Host $Result3
$ListBox.text = $Result3
}
}
############################################## End Function ##############################################
############################################## GroupBox ##############################################
$groupBox = New-Object System.Windows.Forms.GroupBox
$groupBox.Location = New-Object System.Drawing.Size(10,230)
$groupBox.size = New-Object System.Drawing.Size(280,80)
$groupBox.text = "Info:"
$Form.Controls.Add($groupBox)
$FormLabel1 = New-Object System.Windows.Forms.Label
$FormLabel1.Text = "User AD:"
$FormLabel1.ForeColor = "#3009f1"
$FormLabel1.Font = "Microsoft Sans Serif,8"
$FormLabel1.Location = New-Object System.Drawing.Point(10,10)
$FormLabel1.AutoSize = $true
$Form.Controls.Add($FormLabel1)
$FormLabel2 = New-Object System.Windows.Forms.Label
$FormLabel2.Text = "ФИО:"
$FormLabel2.Location = New-Object System.Drawing.Point(10,25)
$FormLabel2.ForeColor = "#3009f1"
$FormLabel2.Font = "Microsoft Sans Serif,8"
$FormLabel2.AutoSize = $true
$groupBox.Controls.Add($FormLabel2)
$FormLabel3 = New-Object System.Windows.Forms.Label
$FormLabel3.Text = "Дата:"
$FormLabel3.Location = New-Object System.Drawing.Point(10,47)
$FormLabel3.ForeColor = "#3009f1"
$FormLabel3.Font = "Microsoft Sans Serif,8"
$FormLabel3.AutoSize = $true
$groupBox.Controls.Add($FormLabel3)
############################################## End GroupBox ##############################################
############################################ InputBox and OutputBox #########################################
$InputBox = New-Object System.Windows.Forms.TextBox
$InputBox.Location = New-Object System.Drawing.Size(65,5)
$InputBox.Size = New-Object System.Drawing.Size(150,20)
$Form.Controls.Add($InputBox)
$outputBox = New-Object System.Windows.Forms.TextBox
$outputBox.Location = New-Object System.Drawing.Size(80,20)
$outputBox.Size = New-Object System.Drawing.Size(180,20)
$outputBox.ReadOnly = $True
$groupBox.Controls.Add($outputBox)
$outputBox2 = New-Object System.Windows.Forms.TextBox
$outputBox2.Location = New-Object System.Drawing.Size(80,42)
$outputBox2.Size = New-Object System.Drawing.Size(180,42)
$outputBox2.ReadOnly = $True
$groupBox.Controls.Add($outputBox2)
############################################ End InputBox and OutputBox #########################################
############################################## ListBox ##############################################
$ListBox = New-Object System.Windows.Forms.TextBox
$ListBox.Location = New-Object System.Drawing.Size(65,30)
$ListBox.Size = New-Object System.Drawing.Size(220,200)
$ListBox.MultiLine = $True #declaring the text box as multi-line
$ListBox.AcceptsReturn = $true
$ListBox.ScrollBars = "Vertical"
$ListBox.AcceptsTab = $true
$ListBox.WordWrap = $True
$ListBox.ReadOnly = $True
$Form.Controls.Add($ListBox)
############################################## End ListBox ##############################################
############################################## search in Russian and in English ##############################################
$regex1 = "[^-a-zA-Z0-9_#.!@]+"
$regex2 = "[^-а-яА-Я0-9_#.!@]+"
$TestName = "Mouse" # Cat или кот
If($TestName -match $regex1){echo "English '$TestName'"}
If($TestName -match $regex2){echo "Русский '$TestName'"}
get-aduser -filter 'name -like "*" ' | select name -expandproperty name
############################################## End search in Russian and in English ##############################################
############################################## Button ##############################################
$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Size(310,20)
$Button.Size = New-Object System.Drawing.Size(110,80)
$Button.Text = "Загрузить данные"
$Button.BackColor = "#d7f705"
$Button.Add_Click({Info})
$Form.Controls.Add($Button)
############################################## End Button ##############################################
$Form.Add_Shown({$Form.Activate()})
[void] $Form.ShowDialog()


