2013-09-06 3 views
2

Я пытаюсь настроить конечную точку-сервер в своей компании и изо всех сил пытаюсь подключиться к нему. Для тестирования я поставил модуль RcLogUtil в пути глобального модуля
C: \ WINDOWS \ system32 \ WindowsPowerShell \ v1.0 \ Modules \ RcLogUtil \
, который экспортирует функции
Ввод-PSSession в пользовательскую конечную точку: Командлет не распознан

'Out-LogToEventLog','New-LogMessage' 

План является чтобы позволить определенному набору пользователей получить доступ только к этим функциям регистрации.

создать SessionConfiguration:

New-PSSessionConfigurationFile -Path C:\Scripts\LoggerEp.pssc ` 
      -SessionType RestrictedRemoteServer ` 
      -LanguageMode FullLanguage ` 
      -ExecutionPolicy Unrestricted ` 
      -ModulesToImport 'RcLogUtil' ` 
      -VisibleFunctions 'Out-LogToEventLog' ` 
      -VisibleCmdlets 'Split-Path' 

Зарегистрируйте:

Register-PSSessionConfiguration -Path C:\Scripts\LoggerEp.pssc ` 
          -Name loggerep ` 
          -ShowSecurityDescriptorUI 

и ввести его на моей локальной машине:

[W0216]> Enter-PSSession -ComputerName mka-ps-endpoint -ConfigurationName loggerep 

Enter-PSSession : One or more errors occurred processing the module 'RcLogUtil' specified in the InitialSessionState object used to create this runspace. See the ErrorRecords property for a complete list of errors. The first error was: The term 'Split-Path' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Enter-PSSession -ComputerName mka-ps-endpoint -ConfigurationName loggerep + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (:) [Enter-PSSession], RunspaceOpenModuleLoadException + FullyQualifiedErrorId : ErrorLoadingModulesOnRunspaceOpen

Огромный вопрос сейчас. почему сессия Unab le, чтобы найти Split-Path? Или как я могу указать конечной точке для загрузки этого конкретного командлета? Я успешно пробовал то же самое с SessionType = 'Default', и это сработало, но со всем беспорядком вокруг него.


Я действительно apreciate любую помощь я могу получить, как я застрял с этим в течение довольно продолжительного времени .. Спасибо!

ответ

0

Существует возможность отключить каждый командлет заранее с помощью -SessionType По умолчанию с -ScriptsToProcess «C: \ Scripts \ LoggerEpStartup.ps1» параметров при создании SessionConfiguration.

New-PSSessionConfigurationFile -Path C:\Scripts\LoggerEp.pssc ` 
       -SessionType Default ` 
       -LanguageMode FullLanguage ` 
       -ExecutionPolicy Unrestricted ` 
       -ModulesToImport 'RcLogUtil' ` 
       -VisibleFunctions 'Out-LogToEventLog' ` 
       -ScriptsToProcess 'C:\Scripts\LoggerEpStartup.ps1' 

C: \ Scripts \ LoggerEpStartup.ps1:

# Commands needed by PSSession (Also the commands used when 
# creating a RestrictedRemoteServer) 
$CmdsToExclude = @(
    'Get-Command' , 'Out-Default' , 
    'Exit-PSSession', 'Measure-Object', 
    'Select-Object' , 'Get-FormatData' 
) 

# Hide any other commandlets except the ones needed 
# to create a remote session 
Get-Command | Where Visibility -eq 'Public' | ForEach-Object { 
    if ($_.Name -notin $CmdsToExclude) { 
     $_.Visibility = 'Private' 
    } 
} 

Но я хочу, чтобы избежать этого ПОДХОД, как это кажется более неуклюжим обходной путь, чем правильное решение.

Смежные вопросы