first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
## Description
|
||||
|
||||
This function can be used to set the volume of your targets PC
|
||||
|
||||
## The Function
|
||||
|
||||
### [Set-Volume]
|
||||
|
||||
In this function we will create an object to allow us to use the Send Keys method to either raise or lower the volume using the following syntax
|
||||
```PowerShell
|
||||
Set-Volume 50
|
||||
```
|
||||
|
||||
```PowerShell
|
||||
Function Set-Volume
|
||||
{
|
||||
Param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[ValidateRange(0,100)]
|
||||
[Int]
|
||||
$volume
|
||||
)
|
||||
|
||||
# Calculate number of key presses.
|
||||
$keyPresses = [Math]::Ceiling( $volume / 2 )
|
||||
|
||||
# Create the Windows Shell object.
|
||||
$obj = New-Object -ComObject WScript.Shell
|
||||
|
||||
# Set volume to zero.
|
||||
1..50 | ForEach-Object { $obj.SendKeys( [char] 174 ) }
|
||||
|
||||
# Set volume to specified level.
|
||||
for( $i = 0; $i -lt $keyPresses; $i++ )
|
||||
{
|
||||
$obj.SendKeys( [char] 175 )
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user