Quantcast
Channel: Windows PowerShell forum
Viewing all 21975 articles
Browse latest View live

Robocopy in Powershell to Delete Persistant Local Profile

$
0
0

Hi Scripters,

I've been stumped by this one for three days straight and It's really getting on my nerves. I'm hoping someone can help me out.

I have been writing a script to assist my service desk to recreate a users local and roaming profiles. My script works, but what occasionally happens (and this happens if you remove the profile with the Windows GUI as well) is that after its removal, the C:\users\Username folder has not been removed (however all corresponding registry keys have been deleted successfully).

So after deleting the profile I scripted in a test-path to ensure it has been removed, and if the folder still exists then try and remove it. Initially I did this with Remove-Item but ran into the max characters in a filepath limit, so turned to Robocopy to do it for me. Here's what I've got so far:

$UID = "Test01" $workstation = "XXX123456" $stubbornFolder = "\\$workstation\c$\users"
$tempFolder="\\$workstation\C$\userdata\emptyfolder" $exempt = Get-ChildItem -path \\$workstation\C$\users | Where {$_.FullName -ne "\\$workstation\c$\users\$UID"} | ForEach-Object {"`""+ $_.FullName + "`"`,"} $exempt = "/XD $exempt" $exempt = $exempt.Substring(0, ($exempt.Length - 1)) $app = "robocopy.exe" $roboArgs = @('/XJ','/E','/MIR','/LEV:1','/R:5', $exempt)& $app $tempFolder $stubbornFolder $roboArgs

Honestly I know at this point it probably looks like a very round about way to do the deletion.

Initially I was just pointing robocopy to purge the specic folder I wanted to wipe (c:\users\username) however that was resulting in MANY nested AppData\AppData\Appdata etc... folders. I looked into this issue and found it was common with profile folders and there were plenty of suggestions to use various Robocopy switches - which I did and had zero effect on the nested folders...

So instead here I've tried pointing robocopy to the parent folder and tried to tell it to purge everything, with the exemption of all other folders...

Any help would be hugely appreciated.



Gather Computer Properties and build HTML Report

$
0
0

Trying to collect hardware information from systems within a list specified at the time the script is ran. The number of systems that the script will reach out to will be different each time. Looking to structure the information for each system in an HTML report.

This is what I have but, does not work and guidance would be appreciated:

$Computer =  $Systems #Pulled from a SQL Query as a table

Function SysInfo($Computer)
{

    $Count = $Computer.count
    $i = 0

    While ($Count -ne $i)
    {
    $Com = $Computer.DNSName[$i]

    $WMI = Get-WMIObject Win32_PingStatus -Computer $Com

    If(!$WMI)
        {
        $info = ConvertTo-HTML -Fragment -Precontent '<h2>Unable to connect to ' + $COM + ' </h2>'
        }
    Else
        {
        $NAM = get-wmiobject Win32_ComputerSystem  -Computer $Com| Select-Object name  | ConvertTo-Html -AS Table -Fragment -PreContent '<h2>System Name</h2>' | Out-String
        $RAM = get-wmiobject Win32_ComputerSystem  -Computer $Com| ForEach-Object {[math]::Round($_.TotalPhysicalMemory / 1GB)}  | ConvertTo-Html -AS Table -Fragment -PreContent '<h2>Total RAM (GB)</h2>' | Out-String #Get the local RAM
        $OS = ((get-wmiobject Win32_OperatingSystem -Computer $Com).caption) | ConvertTo-Html -AS Table -Fragment -PreContent '<h2>Operating System</h2>' | Out-String #Get the Operating System Version
        $SP = ((get-wmiobject Win32_OperatingSystem  -Computer $Com).ServicePackMajorVersion)  | ConvertTo-Html -AS Table -Fragment -PreContent '<h2>Service Pack</h2>' | Out-String #Get the service pack
        $Reboot = (get-wmiobject Win32_OperatingSystem  -Computer $Com).ConvertToDateTime((get-wmiobject Win32_OperatingSystem -Computer $Com).LastBootUpTime)  | ConvertTo-Html -AS Table -Fragment -PreContent '<h2>Last Reboot</h2>' | Out-String #Get the last time the server was rebooted
        $CPU = get-wmiobject Win32_Processor -Computer $Com | select-object name, NumberOfCores, NumberOfLogicalProcessors  | ConvertTo-Html -AS Table -Fragment -PreContent '<h2>Processor Information</h2>' | Out-String #Get the processor name
        $HDD = Get-WMIObject Win32_LogicalDisk -Filter drivetype=3 -Computer $Com | select-object deviceID, volumeName, @{Name="Total Size (GB)";Expression={[math]::Round($_.size / 1GB)}}, @{Name="Free Space (GB)";Expression={[math]::Round($_.freespace / 1GB)}}  | ConvertTo-Html -AS Table -Fragment -PreContent '<h2>HDD Information</h2>' | Out-String #Get HDD Info
        $Sector = Get-WMIObject Win32_Volume -Filter FileSystem='NFTS' -Computer $Com | select-object Label, Blocksize, Name   | ConvertTo-Html -AS Table -Fragment -PreContent '<h2>HDD Sector Information</h2>' | Out-String

        $info = $NAM, $OS, $SP, $Reboot, $CPU, $RAM, $HDD, $Sector
        }


    $SysInfo = $SysInfo + $info

    $i++
    }

    Return $SysInfo
}

$Sys = SysInfo($Computer) 

Cannot change thumbnailPhoto with Active Directory powershell module

$
0
0

Hi,

I'm trying to assign or change the thumbnailPhoto of bulk users with the following script:

$photos = Get-ChildItem -Path "\\server\PhotosFolder" -Recurse -Include *.jpg, *.png, *.gif
Import-Module activedirectory
foreach($photo in $photos)
{
    $thumbnail = [byte[]](Get-Content $photo.FullName -Encoding byte)

    # The baseName of each photo file is the username
    Set-ADUser $photo.BaseName -Replace @{thumbnailPhoto=$thumbnail}

}

When the script is running the following error happens apparently for each user:

Set-ADUser : A value for the attribute was not in the acceptable range of values

Thanks guys for your help.

Modify XML config file using powershell

$
0
0

Hello,

I am new to Powershell and need some assistance. I would like to be able to modify the Data Sources of this sample XML file. I have a script that can do this but the XML file format is much different.

Does anyone have a script handy that accomplishes this?


<?xml version="1.0" encoding="utf-8"?>
<properties name="Template" version="13.4">
<property name="Reports.DMV.TNSEntry" value="Data Source=DEV;Unicode=True" protected="true" />
<property name="Reports.DMW.UserID" value="ABCD" protected="true" />
<property name="Reports.DMV.Password" value="9999" protected="true" />
<property name="Reports.OCD.TNSEntry" value="Data Source=DEVSTAGE;Unicode=True" protected="true" />
<property name="Reports.OCD.UserID" value="WWNA" protected="true" />
</properties>




Thank you all in advance!
 

Write-EventLog with multiple sources

$
0
0

Hello,

I'm trying to create an eventlog and use it to create events with my PowerShell scripts.

Here my code :

New-EventLog -LogName Test -Source DeletionComputer,DeletionUser

Write-EventLog -LogName Test -Source DeletionComputer -Message "Test Computer" -EventId 100 -EntryType Information
Write-EventLog -LogName Test -Source DeletionUser -Message "Test User" -EventId 100 -EntryType Information

When I execute these commands, I have got no error and all sources are well registered in my eventlog. In an other hand, when I check event in the log, I can only find the event relating DeletionComputer. It is impossible to create an event with DeletionUser source and, when I execute the command, I have no error (but nothing happened).

Does someone have an idea ?

Thank you,

Regards,

Olivier

Get-Date -Format FileDateTime

$
0
0

I am trying to use Get-Date -Format FileDateTime and while it works on my test environment, I have some servers with Windows 2012 R2 where the result is very unexpected:

Expected (From documentation @ https://technet.microsoft.com/en-us/library/hh849887.aspx)

PS C:\> get-date -format filedatetime
20160415T0946537051
PS C:\> get-date -format filedatetime
20160415T0946537822

But on the weird server I get something that does not change with milliseconds and does not match the expected format:

PS C:\> get-date -format filedatetime
0ile15aPePi0e
PS C:\> get-date -format filedatetime
0ile15aPePi0e

Both computers are in US with no language pack and the default US internationalization. Also, on both the command Get-Date -Format yyyymmdd_hhmmssfff works as expected.

What am I missing?

Resolve-DnsName error "DNS server failure (raised by: Resolve-DnsName)"

$
0
0

Hi

Trying to get the "com root servers" from the ". root servers" or a ns server of a domain from the "com root servers" fails with Resolve-DnsName, if you try to do the same thing with nslookup it works

The error is:
DNS server failure (raised by: Resolve-DnsName)

Why am I getting this error with Resolve-DnsName?

## Get Root Servers
# Works
Resolve-DnsName -Name . -Type ns
nslookup.exe -type=ns .

## Get com Root Servers
# Fails
Resolve-DnsName -Name com. -Server i.root-servers.net -Type ns
# Works
nslookup.exe -type=ns com. i.root-servers.net

## Get domain ns
# Fails
Resolve-DnsName -Name google.com. -Server m.gtld-servers.net -Type ns
# Works
nslookup.exe -type=ns google.com. m.gtld-servers.net
Thank you

Creating Bulk Users

$
0
0

Hi

PLEASE HELP.

I have a tons of users to create and i want to import them using csv on powershell, but i keep getting errors.

Bulk is my script and my error:

Script

$objOU=[ADSI]"LDAP://OU=Staff,OU=StratOrg,DC=workforcegroup,DC=com"
 $dataSource=import-csv "StratOrg.csv"
 foreach($dataRecord in $datasource) {
 $cn=$dataRecord.GivenName + " " + $dataRecord.Surname
 $sAMAccountName=$dataRecord.GivenName + "." + $dataRecord.Surname
 $givenName=$dataRecord.GivenName
 $sn=$dataRecord.Surname
 $sAMAccountName=$sAMAccountName.ToLower()
 $displayName=$dataRecord.DisplayName
 $userPrincipalName=$sAMAccountName + "@workforcegroup.com"
 $objUser=$objOU.Create("user","CN="+$cn)
 $objUser.Put("sAMAccountName",$sAMAccountName)
 $objUser.Put("userPrincipalName",$userPrincipalName)
 $objUser.Put("displayName",$displayName)
 $objUser.Put("givenName",$givenName)
 $objUser.Put("sn",$sn)
 $objUser.SetInfo()
 $objUser.SetPassword("P@ss123")
 $objUser.psbase.InvokeSet("AccountDisabled",$false)
 $objUser.SetInfo()
 }

Error

The following exception occurred while retrieving member "create": "There is no such object on the server.
"
At line:10 char:11
+  $objUser= <<<< $objOU.create("user","CN="+$cn)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

You cannot call a method on a null-valued expression.
At line:11 char:14
+  $objUser.Put <<<< ("sAMAccountName",$sAMAccountName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:12 char:14
+  $objUser.Put <<<< ("userPrincipalName",$userPrincipalName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:13 char:14
+  $objUser.Put <<<< ("displayName",$displayName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:14 char:14
+  $objUser.Put <<<< ("givenName",$givenName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:15 char:14
+  $objUser.Put <<<< ("sn",$sn)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:16 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:17 char:22
+  $objUser.SetPassword <<<< ("P@ss123")
    + CategoryInfo          : InvalidOperation: (SetPassword:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:18 char:27
+  $objUser.psbase.InvokeSet <<<< ("AccountDisabled",$false)
    + CategoryInfo          : InvalidOperation: (InvokeSet:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:19 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The following exception occurred while retrieving member "create": "There is no such object on the server.
"
At line:10 char:11
+  $objUser= <<<< $objOU.create("user","CN="+$cn)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

You cannot call a method on a null-valued expression.
At line:11 char:14
+  $objUser.Put <<<< ("sAMAccountName",$sAMAccountName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:12 char:14
+  $objUser.Put <<<< ("userPrincipalName",$userPrincipalName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:13 char:14
+  $objUser.Put <<<< ("displayName",$displayName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:14 char:14
+  $objUser.Put <<<< ("givenName",$givenName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:15 char:14
+  $objUser.Put <<<< ("sn",$sn)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:16 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:17 char:22
+  $objUser.SetPassword <<<< ("P@ss123")
    + CategoryInfo          : InvalidOperation: (SetPassword:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:18 char:27
+  $objUser.psbase.InvokeSet <<<< ("AccountDisabled",$false)
    + CategoryInfo          : InvalidOperation: (InvokeSet:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:19 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The following exception occurred while retrieving member "create": "There is no such object on the server.
"
At line:10 char:11
+  $objUser= <<<< $objOU.create("user","CN="+$cn)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

You cannot call a method on a null-valued expression.
At line:11 char:14
+  $objUser.Put <<<< ("sAMAccountName",$sAMAccountName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:12 char:14
+  $objUser.Put <<<< ("userPrincipalName",$userPrincipalName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:13 char:14
+  $objUser.Put <<<< ("displayName",$displayName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:14 char:14
+  $objUser.Put <<<< ("givenName",$givenName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:15 char:14
+  $objUser.Put <<<< ("sn",$sn)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:16 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:17 char:22
+  $objUser.SetPassword <<<< ("P@ss123")
    + CategoryInfo          : InvalidOperation: (SetPassword:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:18 char:27
+  $objUser.psbase.InvokeSet <<<< ("AccountDisabled",$false)
    + CategoryInfo          : InvalidOperation: (InvokeSet:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:19 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The following exception occurred while retrieving member "create": "There is no such object on the server.
"
At line:10 char:11
+  $objUser= <<<< $objOU.create("user","CN="+$cn)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

You cannot call a method on a null-valued expression.
At line:11 char:14
+  $objUser.Put <<<< ("sAMAccountName",$sAMAccountName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:12 char:14
+  $objUser.Put <<<< ("userPrincipalName",$userPrincipalName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:13 char:14
+  $objUser.Put <<<< ("displayName",$displayName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:14 char:14
+  $objUser.Put <<<< ("givenName",$givenName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:15 char:14
+  $objUser.Put <<<< ("sn",$sn)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:16 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:17 char:22
+  $objUser.SetPassword <<<< ("P@ss123")
    + CategoryInfo          : InvalidOperation: (SetPassword:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:18 char:27
+  $objUser.psbase.InvokeSet <<<< ("AccountDisabled",$false)
    + CategoryInfo          : InvalidOperation: (InvokeSet:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:19 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The following exception occurred while retrieving member "create": "There is no such object on the server.
"
At line:10 char:11
+  $objUser= <<<< $objOU.create("user","CN="+$cn)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

You cannot call a method on a null-valued expression.
At line:11 char:14
+  $objUser.Put <<<< ("sAMAccountName",$sAMAccountName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:12 char:14
+  $objUser.Put <<<< ("userPrincipalName",$userPrincipalName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:13 char:14
+  $objUser.Put <<<< ("displayName",$displayName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:14 char:14
+  $objUser.Put <<<< ("givenName",$givenName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:15 char:14
+  $objUser.Put <<<< ("sn",$sn)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:16 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:17 char:22
+  $objUser.SetPassword <<<< ("P@ss123")
    + CategoryInfo          : InvalidOperation: (SetPassword:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:18 char:27
+  $objUser.psbase.InvokeSet <<<< ("AccountDisabled",$false)
    + CategoryInfo          : InvalidOperation: (InvokeSet:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:19 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The following exception occurred while retrieving member "create": "There is no such object on the server.
"
At line:10 char:11
+  $objUser= <<<< $objOU.create("user","CN="+$cn)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

You cannot call a method on a null-valued expression.
At line:11 char:14
+  $objUser.Put <<<< ("sAMAccountName",$sAMAccountName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:12 char:14
+  $objUser.Put <<<< ("userPrincipalName",$userPrincipalName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:13 char:14
+  $objUser.Put <<<< ("displayName",$displayName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:14 char:14
+  $objUser.Put <<<< ("givenName",$givenName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:15 char:14
+  $objUser.Put <<<< ("sn",$sn)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:16 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:17 char:22
+  $objUser.SetPassword <<<< ("P@ss123")
    + CategoryInfo          : InvalidOperation: (SetPassword:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:18 char:27
+  $objUser.psbase.InvokeSet <<<< ("AccountDisabled",$false)
    + CategoryInfo          : InvalidOperation: (InvokeSet:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:19 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The following exception occurred while retrieving member "create": "There is no such object on the server.
"
At line:10 char:11
+  $objUser= <<<< $objOU.create("user","CN="+$cn)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

You cannot call a method on a null-valued expression.
At line:11 char:14
+  $objUser.Put <<<< ("sAMAccountName",$sAMAccountName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:12 char:14
+  $objUser.Put <<<< ("userPrincipalName",$userPrincipalName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:13 char:14
+  $objUser.Put <<<< ("displayName",$displayName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:14 char:14
+  $objUser.Put <<<< ("givenName",$givenName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:15 char:14
+  $objUser.Put <<<< ("sn",$sn)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:16 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:17 char:22
+  $objUser.SetPassword <<<< ("P@ss123")
    + CategoryInfo          : InvalidOperation: (SetPassword:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:18 char:27
+  $objUser.psbase.InvokeSet <<<< ("AccountDisabled",$false)
    + CategoryInfo          : InvalidOperation: (InvokeSet:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:19 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The following exception occurred while retrieving member "create": "There is no such object on the server.
"
At line:10 char:11
+  $objUser= <<<< $objOU.create("user","CN="+$cn)
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

You cannot call a method on a null-valued expression.
At line:11 char:14
+  $objUser.Put <<<< ("sAMAccountName",$sAMAccountName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:12 char:14
+  $objUser.Put <<<< ("userPrincipalName",$userPrincipalName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:13 char:14
+  $objUser.Put <<<< ("displayName",$displayName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:14 char:14
+  $objUser.Put <<<< ("givenName",$givenName)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:15 char:14
+  $objUser.Put <<<< ("sn",$sn)
    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:16 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:17 char:22
+  $objUser.SetPassword <<<< ("P@ss123")
    + CategoryInfo          : InvalidOperation: (SetPassword:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:18 char:27
+  $objUser.psbase.InvokeSet <<<< ("AccountDisabled",$false)
    + CategoryInfo          : InvalidOperation: (InvokeSet:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:19 char:18
+  $objUser.SetInfo <<<< ()
    + CategoryInfo          : InvalidOperation: (SetInfo:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull


Clicking a button on a website

$
0
0

I'm trying to automate some tasks we have to do on a website. Entering the website there are two option, login as registered user or login as admin. This choise has to be made with a radiobutton. After that the password will need to be entered and the login button clicked.

$IE = New-Object -com internetexplorer.application
$IE.visible = $true
$IE.navigate("towebsite(its local)")

do {sleep 5} while ($IE.busy)
<div class="loginBodyRadioLayout"><input type="radio" onclick="javascript:RadioButtonClick();" value="rdoAdmin" name="UserGroup" id="rdoAdmin"><label for="rdoAdmin" id="lblAdminTitle">
                                            System Administrator</label></div>

With this I know how to select the System Administrator radiobutton.

$doc = $IE.document
$myradio = $doc.getElementsByTagName('Input') | ? {$_.type -eq 'radio' -and $_.name -eq 'usergroup'}
$x = 1
$myradio[$x].SetActive()
$myradio[$x].click()
<td><input type="password" maxlength="64" class="loginText_read_greyout" id="txtAdminPass" name="txtAdminPass" disabled=""></td>

With this I know how to enter my password.

$doc.getElementById('txtAdminPass').value="password"
<div class="loginLabel"><span class="loginbtn" id="Label1">Login</span></div>

With this I know how to click the login button.

$doc.getElementById('Label1').click()

Adding a pause to let the page load

do {sleep 5} while($IE.busy)

This next page contains alot of buttons. This is the code for the button I need:

<tr><td width="230" valign="top" height="72" onclick="__doPostBack('ctl08$btnAuthenticationManager','')" class="nowrap" id="ctl08_ViewbtnAuthenticationManager"><div class="btnbase" id="ctl08_btnBase1"><img style="border-width:0px;" alt=" " src="Images/TopMenu_b_Authentication.png" class="trans" id="ctl08_imgAuthBtn1"><table class="btnposition0"><tbody><tr><td width="160px" height="70px"><a href="javascript:__doPostBack('ctl08$btnAuthenticationManager','')" class="maintxt" id="ctl08_btnAuthenticationManager">Authentication<br>Manager</a></td></tr></tbody></table></div></td></tr>

I have tried alot of things like:

$doc.getElementById('ctl08_btnBase1').click()
$doc.getElementById('ctl08_ViewbtnAuthenticationManager').click()
$doc.getElementById('ctl08_btnAuthenticationManager').click()

With all I get the error : You cannot call a method on a null-valued expression.
How can I click that button?

Thanks.

PowerShell Syntax with delegate.

$
0
0

Hello EveryOne 

I implemented some class in c# that work fine. but whene i want to use these class in powershell, i am facing a syntax issue to write one line code.  below is the skeleton of my classes. 


public abstract class IInputObject{ 
///
/// implementation 
/// 

}

public class InputObj : IInputObject
{
///
/// Implementation
///
}

public delegate IInputObject ImportObj(string filePath); 

public delegate void ExportObj(object obj, string filePath);



public class ExtObj{

public void ExportF(object Obj, string path)
public T ImportF<T>(string filePath) where T: class 

}



public class engine{
/// 

public ImportObj Importer;
public ExportObj Exporter;

///

}


main{

engine.Importer = ExtObj.ImportF<InputObj>;
engine.Exporter = ExtObj.ExportF;

}

lines in main function are the two lines that i can't write correclty in powershell. 

thanks for your help. 


File name in zip file corrupted

$
0
0

Hi Folks:     I have a zip file which has a corupted file name - ie. the zip file contains only one file, but the file name is a NULL - winzip, winrar etc. can recognize that there is a file but cannot unzip it as there is no"file name" in the zip archive for the file. Some repair utilities seem to "find" the file but cannot fix the file name in the zip archive - I am a little loath to keep purchasing zip repair utilities that ultimately fail to fix the file. I really need to find a way to fix this file. Any suggestions or info about repair utilties that can deal with fixing the filename header in a zip file would be greatly appreciated.

How do I resolve the "Size limit exceeded for Get-Adgroupmember" error when listing a group with thousands of members?

$
0
0

Hello,

I run the following commands from the 2.0 Command line on a Domain Controller to list the members of a large group (thousands of members) and to count the number of objects (measure-object):

get-adgroupmember "mygroup"

get-adgroupmember "mygroup" | measure-object

Get-ADGroupMember : The size limit for this request was exceeded
At line:1 char:18+ get-adgroupmember <<<<  "mygroup"+ CategoryInfo          : NotSpecified: (mygroup:ADGroup) [Get-ADGroupMember], ADException+ FullyQualifiedErrorId : The size limit for this request was exceeded,Microsoft.ActiveDirectory.Management.Comman
   ds.GetADGroupMember

What do I need to do to resolve this error?  Thanks in advance.

Thanks for your help! SdeDot

Powershell - Copy folder - If Exists at Destination - Rename New Back up

$
0
0
 

Hello,

I am regularly backing up this folder. So next time i back it up I would like it to back up as Workspace2, next time Workspace3 and so forth.

This is so that the back up in destination does not get deleted or overwritten.

$from = "C:\Users\plw\Desktop\Workspace\"

                $to = "C:\Users\plw\ Desktop Back Up\"        


                Copy-Item $from $to -recurse

How can I achieve this?

powershell: access shared mailbox content

$
0
0

Hi

I am trying to create a script that (via sch task) monitors a shared mailbox on office365.

Now I tested it on my normal mailbox and it works just fine. I had thought that I could just point the $email property to the shared mailbox and that would give me the results from the shared mailbox but no.. it still just loads the content of my own inbox.. (fullaccessuser)

Can someone point me in the right direction?


# Destination folder
$destinationFolder = "C:\Users\username\Downloads\Attachment Downloader"

# replace with your email address
$email    = "sharedmailbox1@example.com"
$username = "fullaccessuser@example.com"
$password = "supersecretpassword1"

# load the assembly
Add-Type -Path "C:\Program Files (x86)\Microsoft\Exchange\Web Services\2.1\Microsoft.Exchange.WebServices.dll"

# Create Exchange Service object
$s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1)
$s.Credentials = New-Object Net.NetworkCredential($username, $password)
# $s.TraceEnabled = $true
Write-Host "Trying AutoDiscover... "
$s.AutodiscoverUrl($email, {$true})

if(!$s.Url) {
    Write-Error "AutoDiscover failed"
    return;
} else {
    Write-Host -ForegroundColor Green "AutoDiscover succeeded - $($s.Url)"
}

# Create destination folder
#$destinationFolder = "{0}\{1}" -f $destinationFolder, (Get-Date -Format "yyyyMMdd HHmmss")
#mkdir $destinationFolder | Out-Null

# get a handle to the inbox
$inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($s,[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox)

#create a property set (to let us access the body & other details not available from the FindItems call)
$psPropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$psPropertySet.RequestedBodyType = [Microsoft.Exchange.WebServices.Data.BodyType]::Text;

# Find the items
Write-Host "Searching for items in mailbox... " -NoNewline
$items = $inbox.FindItems(500)
Write-Host -ForegroundColor Green "found $($items.items.Count)"

$inc = 0;
foreach ($item in $items.Items)
{
        # load the property set to allow us to get to the body
    $item.load($psPropertySet)

    # save the metadata to a file
    #$item | Export-Clixml ("{0}\metadata.xml" -f $mailFolder)

    # save all attachments
    foreach($attachment in $item.Attachments) {
        if($attachment.ContentType -notlike "message/*") {
            Write-Host " - $($attachment.Name) ($($attachment.ContentType))"

        }
    }
}




Kindest regards, Martin

optimisation powershell script Eventviewer

$
0
0

Hi everybody,

I try to create a good script to audit my environment.

I create this script with help of some people but it's too long to have result.

Maybe you could help me to improve it ?

$serveur = "servername"
$date = (Get-Date "00:00:00").adddays(-1)
$events = Get-WinEvent -ErrorAction Continue -FilterHashTable @{ LogName = "Security"; StartTime = $date; ID = 4608,4609,4616,4621,4624,4771,5136,5137,5138,5139,5141 } | Where-Object {$_.TimeCreated.date -eq $date.Date}
$events | foreach {

        $Sid = ""
        $compte = ""
        $domaine = ""
        $station = ""
        $ipadress = ""
        $ObjectDN = ""
        $ObjectClass = ""
        $id = $_.id
        $eventXML = [xml]$_.ToXml()
        switch ($eventXML.Event.EventData.Data) {
            {$_.name -eq 'TargetUserName'} {$compte = $_."#text"}
            {$_.name -eq 'TargetDomainName'} {$domaine = $_."#text"}
            {$_.name -eq 'SubjectUserName'} {$compte = $_."#text"}
            {$_.name -eq 'SubjectDomainName'} {$domaine = $_."#text"}
            {$_.name -eq 'WorkstationName'} {$station = $_."#text"}
            {$_.name -eq 'ObjectDN'} {$ObjectDN = $_."#text"}
            {$_.name -eq 'ObjectClass'} {$ObjectClass = $_."#text"}
            {$_.name -eq 'TargetUserSid'} {$Sid = $_."#text"}
            {$_.name -eq 'TargetUSid'} {$Sid = $_."#text"}
            {$_.name -eq 'SubjectUserSid'} {$Sid = $_."#text"}
            {$_.name -eq 'IpAddress'} {
                if ($id -eq "4624") {
                    $ipadress = $_."#text"}
                if ($id -eq "4771") {
                    $ipadress = $_."#text".split(":")[3]
                    }
                }
            }
        if ($ipadress -ne "" -and ($station -eq "" -or $station -eq $null -or $id -eq 4624)) {
            try {$station = (([System.Net.DNS]::GetHostEntry($ipadress)).hostname -split "\.")[0]} catch {}
            }
        if ($compte -ne "SERVICE LOCAL" -and $compte -ne "Système" -and $compte[-1] -ne "$") {
            $_ | select @{n="Serveur";e={$_.MachineName}}, @{n="date";e={$_.TimeCreated}}, @{n="InstanceId";e={$_.Id}}, @{n="catégorie";e={$_.TaskDisplayName}}, @{n="Keywords";e={$_.KeywordsDisplayNames}}, @{n="Sid";e={$Sid}}, @{n="nom du compte";e={$compte.ToUpper()}}, @{n="domaine du compte";e={$domaine}}, @{n="station de travail";e={$station.ToUpper()}}, @{n="Adresse IP";e={$ipadress}}, @{n="ObjectDN";e={$ObjectDN}}, @{n="ObjectClass";e={$ObjectClass}} | Write-Output
            }
            }  | Get-Unique -AsString | Export-Csv c:\test.csv -NoTypeInformation -Encoding unicode -Delimiter ";" 

the script keep information I need and put them on CSV file.

Event with an computer accound and service account are ignored.



Getting Registry values

$
0
0

I would like to get the registry values from HKLM:\SOFTWARE\BMO\SystemCenter\APPLICATIONS\App1 (in server1) & in the server2 registry value changes to HKLM:\SOFTWARE\BMO\SystemCenter\APPLICATIONS\App2) using one script that runs against a server list with Server1 & Server2.

I am sure we can get the values using this 

Get-ItemProperty "HKLM:\SOFTWARE\BMO\SystemCenter\APPLICATIONS\APP1" | Select-Object Environment, Group, State, LOB | Format-List

Can you pls let me know if there is any resource where I can get an output for both servers without having to change the script (in one script) for both server's registry location (as the end of the registry location path changes  APP1 & APP2 - HKLM:\SOFTWARE\BMO\SystemCenter\APPLICATIONS\App1& HKLM:\SOFTWARE\BMO\SystemCenter\APPLICATIONS\App2



VT


AD Power Shell Script

$
0
0

Over 6 months ago I had a script that got the following attributes (below) from all users accounts in ADUC then it exported it to a .csv file... Is there a script already in the script center repository for this?

sAMAccountName

givenName        

sn          

initials  

displayName     

physicalDeliveryOfficeName      

telephoneNumber         

mail       

title       

department      

company 

manager             

info       

streetAddress  

postOfficeBox  

st           

postalCode        

Check to see if user has mailbox in o365

$
0
0

I have 1000+ users I need to check to see if they have a mailbox in o365.  The gotcha is I only have an old report that has the old upn not the new upn.  So I have the Firstname Lastname in the report to run against.  So I can get it to run for the most part and have it export to the screen.

$users = import-csv C:\scripts\usermb.csv

foreach ($user in $users)

{
[bool](Get-Mailbox -Identity $user.name -ErrorAction continue)

}

But I am having issues getting it to export to csv.  Here is what I have.

$users = import-csv C:\scripts\chkmb.csv
$Results = @()

foreach ($user in $users)

{
[bool](($mailbox = Get-Mailbox -Identity $user.name -ErrorAction silentlycontinue))
    {
    $Results += New-Object PSObject -Property ([ordered]@{User=$User.name;
                                                                    Mailbox=$mailbox;
                                                                   })

}
}
$Results | export-csv c:\scripts\chkmb_results.csv

I have definitely gone wrong.  Any guidance would be greatly appreciated. Thanks in advance.

how I can get only the data that I need?

$
0
0

hi,

I have XML file that I need to take only the data, I'm new in powershell :)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns4:plcm-conference-room-list xmlns="http://www.w3.org/2005/Atom" xmlns:ns2="urn:com:polycom:api:rest:plcm-dial-out-participant" xmlns:ns3="urn:com:polycom:api:rest:plcm-conference-room" xmlns:ns4="urn:com:polycom:api:rest:plcm-conference-room-list"><ns3:plcm-conference-room><link href="https://10.233.170.21:8443/api/rest/conference-rooms/97040" rel="self" type="application/vnd.plcm.plcm-conference-room" title="Self Relationship"/><link href="https://10.233.170.21:8443/api/rest/users/LOCAL/golann" rel="urn:com:polycom:api:rest:link-relations:conference-room-owner" type="application/vnd.plcm.plcm-user" title="Conference Room Owner"/><link href="https://10.233.170.21:8443/api/rest/conference-templates/1" rel="urn:com:polycom:api:rest:link-relations:applied-conference-template" type="application/vnd.plcm.plcm-conference-template" title="Applied Conference Template"/><link href="https://10.233.170.21:8443/api/rest/mcu-pool-orders/0" rel="urn:com:polycom:api:rest:link-relations:containing-mcu-pool-order" type="application/vnd.plcm.plcm-mcu-pool-order" title="Containing MCU Pool Order"/><link href="https://10.233.170.21:8443/api/rest/conferences/start-conference" rel="urn:com:polycom:api:rest:link-relations:start-conference-request" type="application/vnd.plcm.plcm-conference-start-request" title="Start Conference Request"/><ns3:owner-first-name>Golan</ns3:owner-first-name><ns3:owner-last-name>Nuri</ns3:owner-last-name><ns3:owner-domain>LOCAL</ns3:owner-domain><ns3:owner-username>golann</ns3:owner-username><ns3:duration-in-minutes>-1</ns3:duration-in-minutes><ns3:conference-room-identifier>97040</ns3:conference-room-identifier><ns3:dial-in-number>97040</ns3:dial-in-number><ns3:conference-template-name>Factory Template</ns3:conference-template-name><ns3:max-participants>-1</ns3:max-participants><ns3:mcu-pool-order-name>Factory Pool Order</ns3:mcu-pool-order-name><ns3:territory-name>Default DMA Territory (dma)</ns3:territory-name><ns3:chairperson-required>false</ns3:chairperson-required><ns3:chairperson-code>180983</ns3:chairperson-code><ns3:conference-code>147258</ns3:conference-code><ns3:entity-tag>42642b96631d501c98ac62d9653536ba</ns3:entity-tag><ns3:auto-dial-out>false</ns3:auto-dial-out><ns3:first-caller-mcu-affinity>false</ns3:first-caller-mcu-affinity><ns3:focus-uri>sip:user003@sfb.guru;gruu;opaque=app:conf:focus:id:RPLVG1F7</ns3:focus-uri><ns3:conference-room-type>LOCAL</ns3:conference-room-type></ns3:plcm-conference-room></ns4:plcm-conference-room-list>

I wrote this that I can see what I need and copy to other file, but I want to do this auto,

Get-Content c:\SmartCascade\$vmrowner.xml | Where-Object { $_.Contains("owner-first-name") }
Get-Content c:\SmartCascade\$vmrowner.xml | Where-Object { $_.Contains("owner-last-name") }
Get-Content c:\SmartCascade\$vmrowner.xml | Where-Object { $_.Contains("dial-in-number") }
Get-Content c:\SmartCascade\$vmrowner.xml | Where-Object { $_.Contains("entity-tag") }
Get-Content c:\SmartCascade\$vmrowner.xml | Where-Object { $_.Contains("focus-uri") }

like this:

<ns3:entity-tag>42642b96631d501c98ac62d9653536ba</ns3:entity-tag>

I only need : 42642b96631d501c98ac62d9653536ba

Thanks!!!

List files older than x days > dump to excel/csv

$
0
0

I've been stumped for a few days now. I have seen one and two line scripts to list files older thanx days, but I am in need of something a little more auditable. I am looking to list the following criteria

a) Files older than x days
b) list path of file
c) list size of file
d) list date last accessed
e) list file owner

All of this dumped into a csv or excel file so it can be sorted and such. Essentially we are trying to find the source of some serious disk eating use. It's possible it's a auto process pointed to the wrong spot, or someone went hog wild and saved a ton of stuff.

 

Viewing all 21975 articles
Browse latest View live