To find all files and folders with ‘excel’ within their name :
Get-ChildItem -filter "*excel*" -Recurse | select name, fullname, lastwritetime,PSIsContainer | Out-GridView
To find all files and folders with ‘excel’ within their name :
Get-ChildItem -filter "*excel*" -Recurse | select name, fullname, lastwritetime,PSIsContainer | Out-GridView
function Register-ScheduledTaskEx
{
<#
.Synopsis
Registers a scheduled task.
.Description
Registers a scheduled task.
Modified to support Folders (path)
#>
param(
# The name of the scheduled task to register
[Parameter(Mandatory=$true,Position=0)]
[string]
$name,
# The path of the scheduled task to register
[Parameter(Mandatory=$false)]
[ValidateNotNull()]
[string]
$path="",
# The Scheduled Task to Register
[Parameter(ValueFromPipeline=$true,
Mandatory=$true)]
[__ComObject]
$Task,
# The name of the computer to connect to.
[string[]]
$ComputerName,
# The credential used to connect
[Management.Automation.PSCredential]
$Credential
)
begin {
Set-StrictMode -Off
}
process {
if ($task.Definition) { $Task = $task.Definition }
foreach ($c in $computerName) {
$scheduler = Connect-ToTaskScheduler -ComputerName $c -Credential $Credential
if ($scheduler -and $scheduler.Connected) {
$folder = $scheduler.GetFolder($path)
if ($Credential) {
$folder.RegisterTaskDefinition($Name,
$Task,
6,
$credential.UserName,
$credential.GetNetworkCredential().Password,
6,
$null)
} else {
$folder.RegisterTaskDefinition($Name,
$Task,
6,
"",
"",
3,
$null)
}
}
}
}
}
. $psScriptRoot\Register-ScheduledTaskEx.ps1
import-module TaskScheduler $ScheduledTask = New-Task $ScheduledTask | add-TaskAction -path "Notepad.exe" -Arguments "" -WorkingDirectory ""| out-null # Note : The folder "\MyCustomFolder" must already exist in the TaskScheduler $ScheduledTask | Register-ScheduledTaskEx -Name "MyCustomScheduledTask" -path "\MyCustomFolder" -ComputerName Localhost | out-null
If you “google” it, you might think that the following command should work to get the list of Active Directory Service Interface (ADSI) installed providers :
[adsi]"ADs:"
It does not work. I think it should (it works in VBS), but it does not.
There is a work arround, ADSI Provider are registered in the registry, si simply type this command :
dir HKLM:\SOFTWARE\Microsoft\ADs\Providers
Get-WmiObject win32_serverconnection | select username,computername,sharename
Frenquently asked questions about everyday real problems in PowerShell