Powershell远程处理:使用Powershell远程配置文件中加载的功能吗? [英] Powershell Remoting: Use Functions loaded in Powershell remote Profile?

查看:227
本文介绍了Powershell远程处理:使用Powershell远程配置文件中加载的功能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否正确,当我在配置了某些功能的RemoteServer上具有配置文件时,这些功能应该在Remote PSSession中可用吗?

Do i get it right that when i have a Profile on a RemoteServer which loads some functions, these functions should be available in a Remote PSSession?

我的测试未成功,是否有特殊的技巧可以使它正常工作?

My tests weren't successfull, is there a special trick to get this working?

我想参考网络共享上的文件夹,以使单个来源上的所有功能都可用.

I want to refer to Folder on a network share to have all Functions on a single source available.

推荐答案

在默认会话配置中使用pssessions时,不会运行任何配置文件脚本.如果要预配置会话(以加载自定义功能,管理单元,模块...),请向新的 sessionconfiguration 添加配置文件脚本. Register-PSSessionConfiguration cmdlet在本地创建并注册新的会话配置电脑.使用 Get-PSSessionConfiguration 查看现有的会话配置. Get-PSSessionConfiguration和Register-PSSessionConfiguration都需要提升的权限(使用以管理员身份运行"选项启动PowerShell).

When you use pssessions with the default session configurations, no profile scripts run. If you want a session to be preconfigured (to load custom functions, snap-ins, modules ...), add a profile script to a new sessionconfiguration. The Register-PSSessionConfiguration cmdlet creates and registers a new session configuration on the local computer. Use Get-PSSessionConfiguration to view existing session configurations. Both Get-PSSessionConfiguration and Register-PSSessionConfiguration require elevated rights (start PowerShell with the "Run as Administrator" option).

Register-PSSessionConfiguration -Name WithProfile -StartupScript $PsHome\Profile.ps1

要使用此预配置的会话,请输入:

To use this preconfigured session you would type:

Enter-PSSession -ComputerName $computername -ConfigurationName WithProfile

(其中$ computername是您注册pssessionconfiguration的RemoteServer的主机名).

(where $computername is the hostname of RemoteServer where you registered the pssessionconfiguration).

《 Powershell Remoting管理员指南》 是有关Powershell Remoting的一个很好的资料.

A good source on powershell remoting is the Administrator's Guide to Powershell Remoting.

这篇关于Powershell远程处理:使用Powershell远程配置文件中加载的功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆