Multiple folders etc

Hi All Scripting Master,

I hope so this is good forum. I want write two script with arguments

  1. Create one folder (without permission to delete main folder, file and subfolders for users - only administrators can delete) in all domain Servers
    Second Script:
  2. Delete .xls files from all created new_folders in all servers and export log to csv
  3. Send mail to user with attachment ( .csv)
    But I have a few problems:
  4. How to set up ACL for folder without permission to delete
  5. I have problem with Invoke-Command if I want use it I must enable WIN-RM on all Servers but I cann’t - Can I replace this command with another one? - If yes - on which?
  6. I don’t know why Export-CSV don’t add logs which files are deleted
  7. Can I write all in one script?
    Script 1)
#import module
Import-Module ActiveDirectory
#define variables
$path = "D:\exist_folder\new_folder"
$servers = Get-ADComputer -Filter {SamAccountName -like "SRV*"}
# create folder or no if exist 
Foreach ($srv in $servers){
If(!(test-path $path))
 Invoke-Command -ComputerName $srv.Name -ScriptBlock { New-Item -ItemType Directory -Force -Path $path }
 

Script 2

 # Remove all .xls files
 $path = "D:\exist_folder\new_folder"
get-childitem $path -include *.xls -recurse | foreach ($_) {remove-item $_.fullname} | Export-Csv -Path c:\path\del.csv
#Send mail with attachment to user which files were deleted
Send-MailMessage -To "User1 " -From "User2 <user2@user.com" -Subject "Delete .xls" -SmtpServer "mail.user.com" -Attachments "C:\path\del.csv"
}

Invoke-Command is PowerShell’s only method of sending commands to remote computers. If you can’t use it, there is no alternative within PowerShell.

Hi Dan,
Thanks for response! OK I understand. I copied script via PS to all servers and run it manually