Test-PSSessionConfigurationFile
Controleert de sleutels en waarden in een sessieconfiguratiebestand.
Syntaxis
Test-PSSessionConfigurationFile
[-Path] <String>
[<CommonParameters>]
Description
Deze cmdlet is alleen beschikbaar op het Windows-platform.
Met deze cmdlet wordt gecontroleerd of een sessieconfiguratiebestand geldige sleutels bevat en of de waarden van het juiste type zijn. Voor opgesomde waarden controleert de cmdlet of de opgegeven waarden geldig zijn.
De cmdlet retourneert $True
als het bestand alle tests doorstaat en $False
als dat niet het geval is. Gebruik de parameter Uitgebreide om eventuele fouten te vinden.
Test-PSSessionConfigurationFile
controleert de sessieconfiguratiebestanden, zoals de bestanden die zijn gemaakt door de New-PSSessionConfigurationFile
-cmdlet. Zie about_Session_Configurationsvoor meer informatie over sessieconfiguraties. Zie about_Session_Configuration_Filesvoor meer informatie over sessieconfiguratiebestanden.
Deze cmdlet is geïntroduceerd in PowerShell 3.0.
Voorbeelden
Voorbeeld 1: Een sessieconfiguratiebestand testen
Test-PSSessionConfigurationFile -Path "FullLanguage.pssc"
True
Voorbeeld 2: Het sessieconfiguratiebestand van een sessieconfiguratie testen
In dit voorbeeld testen we het configuratiebestand dat wordt gebruikt in de beperkte sessieconfiguratie.
De waarde van de parameter Path is het resultaat van de opdracht Get-PSSessionConfiguration
die de Restricted sessieconfiguratie ophaalt. Het pad van het sessieconfiguratiebestand wordt opgeslagen in de waarde van de eigenschap ConfigFilePath van de sessieconfiguratie.
Test-PSSessionConfigurationFile -Path (Get-PSSessionConfiguration -Name Restricted).ConfigFilePath
Voorbeeld 3: Alle sessieconfiguratiebestanden testen
De functie in dit voorbeeld test alle sessieconfiguratiebestanden op de lokale computer. De functie gebruikt de Get-PSSessionConfiguration
cmdlet om alle sessieconfiguraties op te halen. De code in de ForEach-Object
lus geeft het bestandspad weer en test elk van de sessieconfiguraties.
function Test-AllConfigFiles
{
Get-PSSessionConfiguration | ForEach-Object {
if ($_.ConfigFilePath) {
$_.ConfigFilePath
Test-PSSessionConfigurationFile -Verbose -Path $_.ConfigFilePath
}
}
}
Test-AllConfigFiles
C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\Empty_6fd77bf6-e084-4372-bd8a-af3e207354d3.pssc
True
C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\Full_1e9cb265-dae0-4bd3-89a9-8338a47698a1.pssc
VERBOSE: The member 'AliasDefinitions' must contain the required key 'Description'. Add the require key
to the fileC:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\Full_1e9cb265-dae0-4bd3-89a9-8338a47698a1.pssc.
False
C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\NoLanguage_0c115179-ff2a-4f66-a5eb-e56e5692ba22.pssc
True
C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\RestrictedLang_b6bd9474-0a6c-4e06-8722-c2c95bb10d3e.pssc
True
C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\RRS_3fb29420-2c87-46e5-a402-e21436331efc.pssc
True
De eigenschap ConfigFilePath van een sessieconfiguratie bevat het pad van het sessieconfiguratiebestand dat wordt gebruikt in de sessieconfiguratie, indien van toepassing.
Als de waarde van de eigenschap ConfigFilePath is ingesteld (waar), wordt de eigenschapswaarde ConfigFilePath opgehaald (weergegeven). Vervolgens wordt de cmdlet Test-PSSessionConfigurationFile
gebruikt om het bestand te testen in de ConfigFilePath-waarde. De parameter Verbose geeft de bestandsfout wanneer het bestand de test niet doorstaat.
Parameters
-Path
Hiermee geeft u het pad en de bestandsnaam van een sessieconfiguratiebestand (.pssc). Als u het pad weglaat, is de standaard de huidige map. Jokertekens worden ondersteund, maar ze moeten worden omgezet in één bestand. U kunt ook een pad naar een sessieconfiguratiebestand doorsluisen naar Test-PSSessionConfigurationFile
.
Type: | String |
Position: | 0 |
Default value: | None |
Vereist: | True |
Pijplijninvoer accepteren: | True |
Jokertekens accepteren: | True |
Invoerwaarden
U kunt een pad naar een sessieconfiguratiebestand doorsluisen naar deze cmdlet.
Uitvoerwaarden
Notities
Deze cmdlet is alleen beschikbaar op Windows-platforms.
Verwante koppelingen
- Disable-PSSessionConfiguration
- Enable-PSSessionConfiguration
- Get-PSSessionConfiguration
- New-PSSessionConfigurationFile
- New-PSSessionOption
- Register-PSSessionConfiguration
- Set-PSSessionConfiguration
- Test-PSSessionConfigurationFile
- Unregister-PSSessionConfiguration
- WSMan-provider
- about_Session_Configurations
- over_Sessie_Configuratie_Bestanden