We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://ss64.com/nt/displayswitch.html is implemented in windows since version 7.
Simply use that : `
function Write-Log { param ( [Parameter(Mandatory=$true)] [string]$Message, [string]$LogFile = "C:\Logs\DisplaySwitch.log" ) $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $logMessage = "$timestamp - $Message" Write-Output $logMessage try { Add-Content -Path $LogFile -Value $logMessage } catch { Write-Output "error wil writing in file : $LogFile" } } function Switch-DisplayMode { param ( [Parameter(Mandatory=$true)] [ValidateSet("Internal", "Clone", "Extend", "External")] [string]$Mode ) $modeSwitch = @{ "Internal" = "/internal" "Clone" = "/clone" "Extend" = "/extend" "External" = "/external" } $command = "displayswitch.exe" $arguments = $modeSwitch[$Mode] Write-Log -Message "Exécution de la commande : $command $arguments" try { Start-Process -FilePath $command -ArgumentList $arguments -NoNewWindow -Wait Write-Log -Message "Changement d'affichage réussi en mode : $Mode" } catch { Write-Log -Message "Erreur lors de l'exécution de displayswitch.exe : $_" } } #usage: #Switch to clone Switch-DisplayMode -Mode "Clone" `
The text was updated successfully, but these errors were encountered:
No branches or pull requests
https://ss64.com/nt/displayswitch.html is implemented in windows since version 7.
Simply use that :
`
Log definition
function Write-Log {
param (
[Parameter(Mandatory=$true)]
[string]$Message,
[string]$LogFile = "C:\Logs\DisplaySwitch.log"
)
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$logMessage = "$timestamp - $Message"
Write-Output $logMessage
try {
Add-Content -Path $LogFile -Value $logMessage
} catch {
Write-Output "error wil writing in file : $LogFile"
}
}
function Switch-DisplayMode {
param (
[Parameter(Mandatory=$true)]
[ValidateSet("Internal", "Clone", "Extend", "External")]
[string]$Mode
)
$modeSwitch = @{
"Internal" = "/internal"
"Clone" = "/clone"
"Extend" = "/extend"
"External" = "/external"
}
$command = "displayswitch.exe"
$arguments = $modeSwitch[$Mode]
Write-Log -Message "Exécution de la commande : $command $arguments"
try {
Start-Process -FilePath $command -ArgumentList $arguments -NoNewWindow -Wait
Write-Log -Message "Changement d'affichage réussi en mode : $Mode"
} catch {
Write-Log -Message "Erreur lors de l'exécution de displayswitch.exe : $_"
}
}
#usage:
#Switch to clone
Switch-DisplayMode -Mode "Clone"
`
The text was updated successfully, but these errors were encountered: