我正在尝试在 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 文件并将其加载到脚本中来解决它(所以我不需要任何非标准模块)。但是最好在不依赖某些外部任务的情况下运行它:-)