Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all 6937 articles
Browse latest View live

How do I get the boolean value for "enabled" to export in this script

$
0
0

With this script, the value for "enabled" is blank.  How do I get it to show "true" or "false" in the export, if at all possible?

 

FunctionGet-Filtered{

#---------- All users
$strFilter="(&(objectClass=user)(objectCategory=person))"

#===============================================================================================================

# This section will open a window with the AD Structure listed. Select the OU you want to target and the filter selected will be targeted there
#===============================================================================================================
$GetADOU=Get-ADOrganizationalUnit-Filter*-properties* | Select canonicalname,DistinguishedName | sort-object canonicalname | Out-GridView-Title"Pick an OU"-passthru
$ADOU=$GetADOU.distinguishedname
#===============================================================================================================

# This section allows for searching AD
#===============================================================================================================
$objDomain=New-ObjectSystem.DirectoryServices.DirectoryEntry("LDAP://$ADOU")
$objSearcher=New-ObjectSystem.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot=$objDomain
$objSearcher.PageSize= 1000 #--if more than 1000 objects returned, you need to use the PageSize parameter set to 1000
$objSearcher.Filter=$strFilter
$objSearcher.SearchScope="Subtree"
#================================================================================================================

#list the attributes you're wanting
#================================================================================================================


$colProplist="name","displayname","samaccountname","mailnickname","mail","canonicalname","publicdelegates","title","description","department","enabled"


# create empty array

$objArray= @()

foreach ($iin$colPropList){$objSearcher.PropertiesToLoad.Add($i)}

$colResults=$objSearcher.FindAll()

foreach ($objResultin$colResults)
{$objItem=$objResult.Properties
$objItem.name
$objItem.displayname
$objItem.samaccountname
$objItem.mailnickname
$objItem.mail
$objItem.canonicalname
$objItem.publicdelegates
$objItem.title
$objItem.description
$objItem.department
$objItem.enabled

$ItemCol=""|select name,displayname,samaccountname,mailnickname,mail,canonicalname,publicdelegates,title,description,department,enabled
$ItemCol.name= [string]$objItem.name
$ItemCol.displayname= [string]$objItem.displayname
$ItemCol.samaccountname= [string]$objItem.samaccountname
$ItemCol.mailnickname= [string]$objItem.mailnickname
$ItemCol.mail= [string]$objItem.mail
$ItemCol.canonicalname= [string]$objItem.canonicalname
$ItemCol.publicDelegates= [string]$objItem.publicdelegates
$ItemCol.title= [string]$objItem.title
$ItemCol.description= [string]$objItem.description
$ItemCol.department= [string]$objItem.department
$ItemCol.enabled=$objItem.enabled

$objArray+=$ItemCol
}
$objArray | export-csv C:\scripts\reports\Users\accts.csv-NoTypeInformation
} # put a name for the file and the path above.

Extract EDB file to PST

$
0
0

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

If you wish to Extract EDB File to PST then full fill your wish through the wonderful Exchange EDB to PST software which is good quality application to convalesce the EDB file without any mistake in its database. This EDB to PSTsoftware has the full smart potential to re-generate the EDB file information in the fresh outlook PST file. The best feature enrich Exchange EDB to PST software is simply controllable on all Exchange EDB File platform up to 2010.

Extract EDB file data from here:-


http://www.edbrecoveryutility.org/

 

Error: Read text file, replace matching pattern, output to CSV file

$
0
0

Hi everyone,

I'm new to PowerShell. I'm trying to read a text file, find matching pattern ("NO RECORD") and replace it with ("NORECORD") then output the result to a new CSV file. However I didn't get the result I wanted

This is what I've done so far

Data file: sample_data.txt

DATE           AF         QD         QU
09/30/1920      NO RECORD       370.00  NO RECORD  
10/01/1920      NO RECORD       391.00     391.00
10/02/1920      NO RECORD       496.00    MISSING
10/03/1920      NO RECORD       660.00    MISSING
10/04/1920      NO RECORD       881.00    MISSING
10/05/1920      NO RECORD       660.00    MISSING
10/06/1920      NO RECORD       515.00    -9999
10/07/1920      NO RECORD       443.00    NO RECORD
10/08/1920      NO RECORD       443.00    MISSING
10/09/1920      NO RECORD       443.00    443.00
10/10/1920      NO RECORD       443.00    MISSING

 

Code:

$infile = "sample_data.txt"

$outfile = "test.csv"

Get-Content $infile | % {$_ -replace 'NO RECORD','NORECORD'} | Export-Csv -Path $outfile -NoTypeInformation

 

Output: in Excel

 

Length
40
50
49
49
49
49
49
47
50
49
48
48

Any suggestion would be appreciated. Thanks!

 

Extract EDB file to PST file

$
0
0

Want to extract Exchange EDB mailbox in accurate manner? And have no relevant solution overtake such problem. Then be familiar with smart and excellent Exchange EDB file extractor as third party tool which proficiently access Exchange EDB emails after corruption. Software flawless work on your corrupted Exchange EDB file and instantly make it accessible for re-use. Use conveniently re-open Exchange EDB emails and restore all values into Outlook.

Read more- http://www.edbtopstsoft.com

Server 2K8 script to check students config

$
0
0

Hi guys,

We run a course where our students configure active directory with user accounts and permissions on server 2008. After they are done, then comes the laborious task of going through each students config to check they have configured it correctly.

Is there a script out there somewhere that can generate a report telling me if certain parameters have been input correctly?

If so this would be a great help

Any free vmware backup solutions?

$
0
0

As per the title really, i need some way of backing up VMware virtual machines without having to shut down the VMs

Ideally free, but if not as cheap as possible!

Any suggestions or thoughts

Gwmi Printer Published = False

$
0
0

Hello,Iwould setthe variable "Published"from"True" to "False".
Here is mycode:

gwmi win32_printer -Filter "Published='True'" | Select-Object Name

Thanks

Invoke-Command with ScriptBlock problem

$
0
0

I'm try to write a code to scan a system on remote PC and also delete files from different location.


I have try following code but it didn't work.

 

$command = {
    function::Stinger-Copy-Files
    Remove-Item "C:\TEMP\*" -recurse;
    Remove-Item "C:\Windows\Temp\*" -recurse;
    Remove-Item "C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" -recurse;
    function::Stinger-Run-Scan
}

Invoke-Command -ComputerName $computerName -ScriptBlock { $command }


When I run this I get following error message

PS E:\Script\Help Script> Invoke-Command -ComputerName PC-number-ScriptBlock { $command }
[PC-number] Connecting to remote server PC-number failed with the following error message :
The client cannot connect to the destination specified in the request. Verify that the
service on the destination is running and is accepting requests. Consult the logs and
documentation for the WS-Management service running on the destination, most commonly IIS
or WinRM. If the destination is the WinRM service, run the following command on the
destination to analyze and configure the WinRM service: "winrm quickconfig". For more
information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (PC-number:String) [], PSRemotingTransportExceptio
   n
    + FullyQualifiedErrorId : CannotConnect,PSSessionStateBroken


to fix this problem I have tried following code


psexec -s -e \\$computerName cmd /c winrm quickconfig -quiet

Which worked.

 

1. How can I make the Invoke-Command to take multiple commands
2. Enable the PSRemote commands will harm the PC. What are the down side to this.e.g. winrm quickconfig


Thank you

 


Back Up and Restore Lync Contacts Using PowerShell

$
0
0

There might come a time when Lync contacts are lost when you move a Lync user from one pool to another pool. This has happened to me. If you regularly back up Lync contacts, you can easily restore the missing contacts. I'll walk you through how to back up and restore Lync contacts using Windows PowerShell commands in the Lync Server 2013 Management Shell. The areas I'll address are:

Read More

How do I do the following?

$
0
0

I have the following script which works.   It does everything I want it to do.  But I wanted to add some more "cool" functionality to it.     How would I do the following.  If $model -LIKE '*MD*' Then make the cell RED with BLACK font. Else continue as usual.

$erroractionpreference = “SilentlyContinue” 

$a = New-Object -comobject Excel.Application 

$a.visible = $True

$b = $a.Workbooks.Add() 

$c = $b.Worksheets.Item(1)

$c.Cells.Item(1,1) = “Computer Name” 

$c.Cells.Item(1,2) = “OS Version” 

$c.Cells.Item(1,3) = “IP vLan” 

$c.Cells.Item(1,4) = “Description” 

$c.Cells.Item(1,5) = “Model” 

$d = $c.UsedRange 

$d.Interior.ColorIndex = 37   

$d.Font.ColorIndex = 1       

$d.Font.Bold = $True 

$d.EntireColumn.AutoFit()

$intRow = 2

$pc = Get-Content "c:\temp\tmp\xp\xpsccm.txt"

import-module activedirectory 

foreach ($machine in $pc)

{   

       $computerName = Get-WMIObject -class Win32_ComputerSystem -computername $machine | Select-Object -ExpandProperty name; 

            $computerOS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $machine | Select-Object -ExpandProperty version;

            $getip = ([version](Test-Connection $machine -Count 1).IPV4Address.IPAddressToString).Build; 

            $desc = (Get-ADComputer $machine -Properties Description).description 

            $model = (Get-WmiObject -Class Win32_ComputerSystem -ComputerName $machine).model

            $c.Cells.Item($intRow, 1) = $computerName

            $c.Cells.Item($intRow, 2) = $computerOS

            $c.Cells.Item($intRow, 3) = $getip 

            $c.Cells.Item($intRow, 4) = $desc

            $c.Cells.Item($intRow, 5) = $model

            $intRow += 1 

            $d.EntireColumn.AutoFit() 

 

}

call csvde in powershell

$
0
0

I am trying to call CSVDE in powershell passing some credentials to it. Its part of a bigger picture so I cant just run CSVDE seperately. 

Cant seem to get it right. 

 

Any ideas?

 

Thanks in advance.

 

___

 

$cred = Get-Credential

$domain = "testdomain"

$cmd = "csvde -f $outputFile -r "(objectclass=msExchDynamicDistributionList)" -s $domain"

$outputFile = "c:\scripts\DynamicGroups.csv"

#Get Groups:

Invoke-command -ScriptBlock {$cmd}

 

Output from two different areas in a single line.

$
0
0

I need to combine the output of two areas in a single line for each server. I am trying to find what is the best way to do that.

 

$servers=Get-ContentC:\Temp\srv.txt

$collection= $()

foreach ($serverin$servers)

{

Get-ADComputer-Filter {Name-Like$server} -ServerMyCompany.domain.com-Property*|selectName,Created,Enabled,LastLogonDate,OperatingSystem|Export-Csv-LiteralPathC:\Temp\S_ServerInAdInfo.csv-NoTypeInformation-Append

}

 

Gives:

Name

Created

Enabled

LastLogonDate

OperatingSystem

MYDEVSERVER1

12/6/2007 10:52

TRUE

11/11/2014 17:09

Windows Server 2003

MYDEVSERVER2

12/7/2007 10:52

TRUE

11/12/2014 17:09

Windows Server 2008

 

But I want to use the following command in the same script so I can get service Info for those servers as shown below (highlighted in yellow)

 

$HealthService=Get-WmiObjectwin32_service-ComputerName$server-Filter"Name = 'SNMPTRAP'"-ErrorActionSilentlyContinue|selectState

Name

Created

Enabled

LastLogonDate

OperatingSystem

State

MYDEVSERVER1

12/6/2007 10:52

TRUE

11/11/2014 17:09

Windows Server 2003

Stopped

MYDEVSERVER2

12/7/2007 10:52

TRUE

11/12/2014 17:09

Windows Server 2008

Running

Thanks in advance.

Solve out Outlook OST file recovery problem through OST PST Recovery Software

$
0
0

As we all know that it is too difficult to understand the occult reason of corruption in OST file, So as like this it is too difficult to do secure recovery manual. So without taking high risk of data loss you should choose good third party tool for perfect recovery betterment. With this utility you can easily fight against any corruption issues safely and securely. As a good review I like to recommend one known such OST recovery utility through which definitely resolve your OST corruption issues.

Read more

OST to PST Recovery

OST to PST Converter

Exchange 2010 Export Mailbox o PST

$
0
0

For simple recovering Exchange EDB emails after corruption is quite difficult with manually, but via excellent third party tool user can fight against any corruption issue. Now be familiar with such perfect Exchange email converter utility which shrewd to repair corrupted database. Its manly developed to give positive satisfaction to user so that they pull out their data from corrupted Exchange database and then export Exchange 2010 Mailbox to PST file

Read more- http://www.ms.exchange.edbtopsttool.com

http://www.convert.edbtopst.info/freeware

Normal 0 false false false EN-US X-NONE X-NONE

 

 

Refreshing a user profile to a fixed state for every logon

$
0
0

For something resembling kiosk-type usage, I need to create a non-persistent Windows 8.1 user account that resets itself to a pre-configured state every time a user logs on to it, then reverts any changes that are made locally during the session (downloaded files, saved Windows network passwords, interface settings, browser history, etc).

A Mandatory User Profile (http://msdn.microsoft.com/en-us/library/windows/desktop/bb776892(v=vs.85).aspx) sounds like it would be exactly what I want, but from everything I've found, it seems to be set up using tools available only in Pro or Enterprise versions of Windows, whereas I need it in garden variety Windows 8.1.  (I'd also like the option of keeping the profile local, and I think they might have to be stored on a remote server?)

I'm *completely* new to PowerShell, so here's what I came up with.  It doesn't work yet, and I'm aware of at least some of the problems with it, but it should at least get the idea across.  In a neater world, it would just be the Logoff script since it's a better time to slow the system down, but the Logon script and IsTainted.txt is in case the account doesn't get logged off properly for whatever reason.

Logon.ps1
---------
if (get-content C:\Users\AdminAccount\KioskProfile\IsTainted.txt) {
    rm -recurse -force C:\Users\NonPersistentUser\
    cp C:\Users\AdminAccount\KioskProfile\NonPersistentUser\ -destination C:\Users\NonPersistentUser\ -recurse -force
} else {
    Set-Content -path C:\Users\AdminAccount\KioskProfile\IsTainted.txt -value "1"
}

Logoff.ps1
----------
rm -recurse -force C:\Users\NonPersistentUser\
cp C:\Users\AdminAccount\KioskProfile\NonPersistentUser\ -destination C:\Users\NonPersistentUser\ -recurse -force
Clear-Content C:\Users\AdminAccount\KioskProfile\IsTainted.txt

The first problem I'm running into is that it's telling me the script doesn't have permission to delete the user folder.  I'm running PowerShell as administrator from within the administrator account, so how can it not have permission?  (Once it works, I plan on scheduling tasks for the scripts following the directions on http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx)

Another (bigger) question is whether or not I can even nuke and replace a profile at all as I'm logging into / out of it.  Is that timing going to be a problem?

One more thing I think is going to go wrong is retaining file permissions.  How do I preserve the correct ownership and permissions with the script while copying between profile folders?

I also hit a speed bump with the computer not running scripts, but "Set-ExecutionPolicy RemoteSigned" seemed to resolve it.  That's not a security risk, is it?  These will likely be the only two scripts I'd ever like run on this system.

Any advice / suggestions?  There are clearly a lot of experienced and talented admins here, so if there's a better way to do this, even using different tools or methods, please do let me know.  Especially if it doesn't involve me hacking around wildly like this.  Just keep in mind that this is the "Home" edition of Windows 8.1, and not Pro.

Thanks!


regex

$
0
0

I have several files that I need to parse for a user's name and phone number; however, I am unable to get this data parsed out correctly. In the following code, I am trying to retrieve the fullname, but it returns the first name:

$str='empid="12345" fullname="Doe, John" phonenumber="123-456-7890" otherdata=""...'| Select-String -pattern "fullname"

$var=@($str -split "fullname=")[-1]

$var = $var -replace '"',""

"$var" -match "\w* \w*"

$Matches

The file contains the following string:

 

empid="12345" fullname="Doe, John" phonenumber="123-456-7890" otherdata=""...

Split string

$
0
0

I know this must be a simple answer, but I'm just starting out and don't have any formal training.

The following line will give me a list of users connected to a Citrix published app:

Get-XASession -BrowserName "Published App" | Where-Object { $_.State -eq "Active" } | Select AccountName

The results is DomainName\UserName, but I need to split that into just the UserName.

Once I get passed this problem, I plan to query active direct for user name and phone number, but I need to figure out how to split the AccountName.

Thanks in advance, for any help.

Howto modify tab text file and insert Pipe-Delimiters

$
0
0

Hi,

I my case I have tab delimited text file in that i want to change the 2nd field value and convert the tab/spaces to pipe delimted CSV file.

I have conversion list, if 1 in 2nd field to be replaced with 101000011, if 3 then 101000033 and so on.

dot(.) for display of tab delimited, they are not in text file.

Tab-Delimited Text File

2xxxxxxxxx17 ...1........ xxxxxxxxxxxxxxxxxxxxxxxx.......0000029961104599xxxx1220J.....1PU1366512....000000071800002
2yyyyyyyyy17....3.........xxxxxxxxxxxxxxxxxxxxxxxx.......0000021991104599xxxxY2014.....2180000000.....016420000264313

Pipe-Delimited Output.csv

2xxxxxxxxx17|101000011|xxxxxxxxxxxxxxxxxxxxxxxx|0000029961104599xxxx1220J|1PU1366512|000000071800002
2yyyyyyyyy17|101000033|xxxxxxxxxxxxxxxxxxxxxxxx|0000021991104599xxxxY2014|2180000000|016420000264313

Iterating powershell code for scheduled reboot jobs -REQUIRES URGENT HELP

$
0
0

Hello Everyone,

Being windows administrator it is necessary to patch the Servers till the latest and so its necessary to Reboot them after patching in order to see the effects the patches.

I have recently automated the Patch Management Process by integrating SCCM+SCO+ITSM tool and the complete Patching for a list of servers is taken care automatically on the respective schedule times.

The only pre-requisite is to maintain an inventory for all the servers with patching schedule details.

The PROBLEM BEGINS HERE, although patching is automated but reboot is suppressed throughout the deployment and now the task is "TO REBOOT THE LIST OF SERVERS THAT RECENTLY GOT PATCHED".

This is how the Inventory of patching schedule looks like :

File.csv(view is modified for legibility)

 

ComputerName	Date	       StartTimeEnd Time
vm-server1	12/22/2014	8:00	10:00
vm-server2	02/22/2015	6:00	8:00
vm-server3	12/22/2014	8:00	10:00
vm-server4	01/07/2015	14:00	16:00

 

When it comes to patching the till the deployment of patches everything works but the problem is in coding the script for rebooting the servers.

MAJOR POINTS ON REBOOT:

* The reboot should be completed within the Start Time and End Time ,but should start only after the systems are patched.

* The reboot script should keep on iterating on the list of servers and keep updating the reboot status and should stop  30 mins before end time.

All this points I have developed this powershell code with various assurance that systems are rebooted only when reboot is pending on system and once rebooted they are not rebooted again.

* Please suggest me if the below solution is OK for the purpose or How well can I optimize this code to work for me :

#import of Schedules
$csv
=Import-Csv D:\file.csv          
$StartTime
=([datetime]$($csv.Time[0])).AddMinutes(30).ToString('HH:mm:ss')
$EndTime
=([datetime]$($csv.'End Time'[0])).AddMinutes(-30).ToString('HH:mm:ss')
$Time2
=Get-Date-DisplayHintTime-Format("HH:mm:ss")
$TimeDiff1
=New-TimeSpan $Time2 $EndTime
#sleep time for iterations
$sleeptime_iterate
=($TimeDiff1.Hours/6)*3600

Start-Sleep-Seconds3    #initial sleep time
$i
=0
do
{
$CIReport
=Import-Csv D:\final.csv
Foreach($Computer in $CIReport.ComputerName)
{

$PendFileRename
,$Pending,$SCCM = $false,$false,$false
                        $CBSRebootPend
= $null

# Making registry connection to the local/remote computer
$RegCon
=[Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"LocalMachine",$Computer)



    
# Query WUAU from the registry
$RegWUAU
= $RegCon.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\")
$RegWUAURebootReq = $RegWUAU.GetSubKeyNames()
$WUAURebootReq = $RegWUAURebootReq -contains "
RebootRequired"

# Query PendingFileRenameOperations from the registry
$RegSubKeySM = $RegCon.OpenSubKey("
SYSTEM\CurrentControlSet\Control\Session Manager\")
$RegValuePFRO
= $RegSubKeySM.GetValue("PendingFileRenameOperations",$null)

# Closing registry connection
$RegCon
.Close()
                        $lastPatched
=$Computer |%{ gwmi win32_quickfixengineering -computer $_ |?{ $_.installedon }| sort @{e={[datetime]$_.InstalledOn}}|select-last1}
$date
=Get-Date
                       
if($date -eq $lastPatched)
                       
{
                        $Datematched
="True"
                       
}
                       
else
                       
{
                        $Datematched
="False"
                       
}
# If PendingFileRenameOperations has a value set $RegValuePFRO variable to $true
If($RegValuePFRO)
{
$PendFileRename
= $true

}#End If ($RegValuePFRO)

# Determine SCCM 2012 Client Reboot Pending Status
# To avoid nested 'if' statements and unneeded WMI calls to determine if the CCM_ClientUtilities class exist, setting EA = 0
$CCMClientSDK
= $null
                        $CCMSplat
=@{
                           
NameSpace='ROOT\ccm\ClientSDK'
                           
Class='CCM_ClientUtilities'
                           
Name='DetermineIfRebootPending'
                           
ComputerName=$Computer
                           
ErrorAction='SilentlyContinue'
                           
}
                        $CCMClientSDK
=Invoke-WmiMethod@CCMSplat
If($CCMClientSDK)
                           
{
                               
If($CCMClientSDK.ReturnValue-ne 0)
       
{
       
Write-Warning"Error: DetermineIfRebootPending returned error code $($CCMClientSDK.ReturnValue)"
                           
       
}#End If ($CCMClientSDK -and $CCMClientSDK.ReturnValue -ne 0)

       
If($CCMClientSDK.IsHardRebootPending-or $CCMClientSDK.RebootPending)
       
{
        $SCCM
= $true

       
}#End If ($CCMClientSDK.IsHardRebootPending -or $CCMClientSDK.RebootPending)

                           
}#End If ($CCMClientSDK)
                       
Else
                           
{
                                $SCCM
= $null

                           
}                       
                       
                       
# If any of the variables are true, set $Pending variable to $true
If($CBSRebootPend -or $WUAURebootReq -or $SCCM )
{
$Pending
= $true

}#End If ($CBS -or $WUAU -or $PendFileRename)

# Creating Custom PSObject and Select-Object Splat
                        $SelectSplat
=@{
                           
Property=('Computer','CBServicing','WindowsUpdate','CCMClientSDK','RebootPending','ScheduleMatch')
                           
}
New-Object-TypeNamePSObject-Property@{
Computer=$Computer
CBServicing=$CBSRebootPend
WindowsUpdate=$WUAURebootReq
CCMClientSDK=$SCCM
RebootPending=$Pending
                               
ScheduleMatch=$Datematched
}|Select-Object@SelectSplat|Export-Csv D:\Reboot\Status.csv -NoTypeInformation

#Reboot Module-if(Conditions are true)
if($WUAURebootReq -eq "True"-and $SCCM -and"True"-and $Pending -eq "True"-and $Datematched -eq "True")
{
Try
{
$LastBootUpTime
=Get-WmiObjectWin32_OperatingSystem-Comp localhost |Select-ExpLastBootUpTime
$RebootTime
=[System.Management.ManagementDateTimeConverter]::ToDateTime($LastBootUpTime)
if($RebootTime.Date-eq (Get-Date).Date)
{
$Timer0
=Get-Date
$SelectSplat3
=@{
                           
Property=('Computer','Status','TimeStamp')
                           
}
New-Object-TypeNamePSObject-Property@{
Computer=$Computer
                               
TimeStamp=$Timer0
Status="Already Rebooted"
}|Select-Object@SelectSplat3|Export-Csv D:\Reboot\Already_Rebooted.csv -NoTypeInformation-Append

}
else{
Restart-Computer-Computername $Computer -force -ErrorAction
}
}
catch
{
$Timer1
=Get-Date
$SelectSplat1
=@{
                           
Property=('Computer','Status','TimeStamp')
                           
}
New-Object-TypeNamePSObject-Property@{
Computer=$Computer
Status="Not Rebooted"
                               
TimeStamp=$Timer1
}|Select-Object@SelectSplat1|Export-Csv D:\Reboot\NotRebooted.csv -NoTypeInformation-Append
}
}#end of IF
Else
{
$Timer2
=Get-Date
$SelectSplat1
=@{
                           
Property=('Computer','Status','TimeStamp')
                           
}
New-Object-TypeNamePSObject-Property@{
Computer=$Computer
Status="Not Rebooted"
                               
TimeStamp=$Timer2
}|Select-Object@SelectSplat1|Export-Csv D:\Reboot\NotRebooted.csv -NoTypeInformation-Append}


}#End Foreach ($Computer in $ComputerName)

Start-Sleep-Seconds $sleeptime_iterate
$i
++
$Time3
=Get-Date-DisplayHintTime-Format("HH:mm:ss")
$TimeDiff
=New-TimeSpan $Time3 $EndTime
}while($TimeDiff.Hours-ge 0-and $TimeDiff.TotalMinutes-gt 30)

how to tick a box?

$
0
0

Get-ADUser SmithJ -Properties *   this of course works and one of the properties it returns is:  ProtectedFromAccidentalDeletion    : False   How do you change that to :TRUE ?   We have an OU with systems in it that can't be moved or deleted.   if they get moved then they no longer get a very custom GPO applied to them. 

 

 

Viewing all 6937 articles
Browse latest View live


Latest Images