我有一个字符串,我使用代码拆分$CreateDT.Split(" ").我现在想以不同的方式操纵两个单独的字符串.如何将这些变量分成两个变量?
我有以下代码,应该通过文件共享中的文件夹,然后将所有权限转换为读取权限。但是,存在一个问题:它不会替换仅添加到他们那里的权限。其次,如果文件夹没有继承权限,则会显示错误信息
Set-Acl:该进程不具有此操作所需的“ SeSecurityPrivilege”特权。
我已经检查了权限,并对它们拥有完全控制权
function NotMigrated($SiteURL, $Folder) {
try {
$SiteString=[String]$SiteURL
$pos = $SiteString.LastIndexOf("/")
$Site = $SiteString.Substring($pos+1)
$parent=((get-item $Folder ).parent).Fullname
$AllFolders = Get-ChildItem -Recurse -Path $Folder |? {$_.psIsContainer -eq $True}
$FilesInRoot = Get-ChildItem -Path $Folder | ? {$_.psIsContainer -eq $False}
$acl= get-acl $Folder
foreach ($usr in $acl.access) {
$acl.RemoveAccessRule($usr)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($usr.IdentityReference,"Read","none","none","Allow")
$Acl.AddAccessRule($rule)
}
$acl | Set-Acl
} catch { continue }
#Loop through all folders (recursive) that exist within the folder supplied by the operator
foreach ($CurrentFolder in …Run Code Online (Sandbox Code Playgroud) 我有一个方法,如果找到一个特殊字符,它会捕获一个if语句.如果找到特殊字符的位置并将其替换为_A,我现在想做什么
一些例子
test#成为 test_A
我#希望#某人#this #the#answer#成为 I_Ahope_Asomeone_Aknows_Athe_Aanswer_A
或者如果它有多个特殊字符
我是否必须遍历整个字符串,当我到达该字符时将其更改为_A或是否有更快的方法来执行此操作?