我正在尝试在Windows Server 2012 R2上的文件服务器资源管理器中的分类规则中使用活动目录powershell模块。
当我尝试执行时:
Import-Module ActiveDirectory
它将崩溃(我假设)并且不再更新分类属性。
我尝试设置脚本参数-ExecutionPolicy Unrestricted,但这没有帮助。
任何人都知道如何让它发挥作用?
提前致谢,
埃里克
更新添加的非工作代码:
# Global variables available:
# $ModuleDefinition (IFsrmPipelineModuleDefinition)
# $Rule (IFsrmClassificationRule)
# $PropertyDefinition (IFsrmPropertyDefinition)
#
# And (optionally) any parameters you provide in the Script parameters box below,
# i.e. "$a = 1; $b = 2" . The string you enter is treated as a script and executed so the
# variables you define become globally available
# optional function to specify when the behavior of this script was last modified
# if it consumes additional files. emit one value of type DateTime
#
# function LastModified
# {
# }
# required function that outputs a value to be assigned to the specified property for each file classified
# emitting no value is allowed, which causes no value to be assigned for the property
# emitting more than one value will result in errors during classification
# begin and end are optional; process is required
#
function GetPropertyValueToApply
{
# this parameter is of type IFsrmPropertyBag
# it also has an additional method, GetStream, which returns a IO.Stream object to use for
# reading the contents of the file. Make sure to close the stream after you are done reading
# from the file
param
(
[Parameter(Position = 0)] $PropertyBag
)
process
{
Import-Module activedirectory
$users = Get-ADUser -filter * -Properties SID,Department
return "dummy result";
}
}
注意:这在powershell控制台中完全正常,但问题并非如此。它将代码作为文件服务器资源管理器的分类器运行。
现在只需创建一个包含Get-ADUser结果的CSV文件,然后将其加载到脚本中(因此我不需要任何非标准模块)。但是,如果不依赖某些外部任务来运行它会更好: - )
答案 0 :(得分:0)
已解决(现在感觉有点愚蠢:-(),仅供参考,如果有人有同样的问题。
分类脚本是从文件服务器资源管理器服务(而不是您正在查看的UI)执行的,该服务在系统帐户下运行。
因此,您需要修改服务正在运行的帐户,或者授予帐户访问您需要访问的对象的权限。在我的案例中,Active Directory。