Test-PSSessionConfigurationFile
Controleert de sleutels en waarden in een sessieconfiguratiebestand.
Syntax
Test-PSSessionConfigurationFile
[-Path] <String>
[<CommonParameters>]
Description
Deze cmdlet is alleen beschikbaar op het Windows-platform.
Deze cmdlet controleert of een sessieconfiguratiebestand geldige sleutels bevat en de waarden van het juiste type zijn. Voor opgesomde waarden controleert de cmdlet of de opgegeven waarden geldig zijn.
De cmdlet retourneert $True of het bestand aan alle tests voldoet en $False als dit niet het geval is. Als u fouten wilt vinden, gebruikt u de uitgebreide parameter.
Test-PSSessionConfigurationFile Controleert de sessieconfiguratiebestanden, zoals de bestanden die zijn gemaakt door de New-PSSessionConfigurationFile cmdlet. Zie about_Session_Configurations voor informatie over sessieconfiguraties. Zie about_Session_Configuration_Files voor 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 configuratie van de beperkte sessie.
De waarde van de parameter Path is het resultaat van de Get-PSSessionConfiguration opdracht waarmee de configuratie van de beperkte sessie wordt opgehaald. 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 aanwezig.
Als de waarde van de eigenschap ConfigFilePath is ingevuld (waar is), wordt de eigenschapswaarde ConfigFilePath door de opdracht opgehaald (afgedrukt). Vervolgens wordt de Test-PSSessionConfigurationFile cmdlet gebruikt om het bestand te testen in de ConfigFilePath-waarde . De uitgebreide parameter retourneert de bestandsfout wanneer het bestand de test mislukt.
Parameters
Hiermee geeft u het pad en de bestandsnaam van een sessieconfiguratiebestand (.pssc). Als u het pad weglaat, is de standaardmap 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 |
| Accept pipeline input: | True |
| Accept wildcard characters: | True |
Invoerwaarden
U kunt een pad naar een sessieconfiguratiebestand doorsluisen naar Test-PSSessionConfigurationFile.
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
- about_Session_Configuration_Files
Feedback
Feedback verzenden en weergeven voor