Test-PSSessionConfigurationFile
Controleert de sleutels en waarden in een sessieconfiguratiebestand.
Syntaxis
Default (Standaard)
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 ingevuld (waar), dan wordt de waarde van de eigenschap ConfigFilePath afgedrukt. Vervolgens wordt de cmdlet Test-PSSessionConfigurationFile gebruikt om het bestand te testen in de ConfigFilePath-waarde. De parameter Verbose geeft de bestandsfout terug wanneer het bestand niet slaagt voor de test.
Parameters
-Path
Hiermee geeft u het pad en de bestandsnaam van een sessieconfiguratiebestand (.pssc). Als u het pad weglaat, is de standaardwaarde 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.
Parametereigenschappen
| Type: | String |
| Default value: | None |
| Ondersteunt jokertekens: | True |
| DontShow: | False |
Parametersets
(All)
| Position: | 0 |
| Verplicht: | True |
| Waarde uit pijplijn: | True |
| Waarde uit pijplijn op eigenschapsnaam: | True |
| Waarde van resterende argumenten: | False |
CommonParameters
Deze cmdlet ondersteunt de algemene parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction en -WarningVariable. Zie about_CommonParametersvoor meer informatie.
Invoerwaarden
String
U kunt een pad naar een sessieconfiguratiebestand doorsluisen naar deze cmdlet.
Uitvoerwaarden
Boolean
Notities
Deze cmdlet is alleen beschikbaar op Windows-platforms.
Verwante koppelingen
- Schakel-PSSessieConfiguratie uit
- Schakel-PSSessieConfiguratie in
- Get-PSSessionConfiguration
- New-PSSessionConfigurationFile
- New-PSSessionOption
- Register-PSSessionConfiguration
- Set-PSSessionConfiguration
- Testen-PSSessieConfiguratiebestand
- Unregister-PSSessionConfiguration
- WSMan-provider
- about_Session_Configurations
- over_Sessie_Configuratie_Bestanden