Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all 15028 articles
Browse latest View live

Network binding order‎ without nvspbind

$
0
0

Hi,

I am lookingto put anewpossibility, theNICbind orderwithPowerShell.

The use of nvspbind isunfortunatelynot an option.

$ServerName = "work"

$objReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $ServerName)
$objRegKey = $objReg.OpenSubKey("SYSTEM\\Currentcontrolset\\Services\\TCPIP\\Linkage" )
$arrItem = $objRegKey.GetValue("Bind")
$arrItem

Seeking an opportunity to re-sort the outputof $arrItemand the RegKeythen rewrite.

Does anyone have an idea?

 


Powershell to import a computer list and remove an icon

$
0
0
I need to import a list of domain PCs. For each entry, I have to remove a .lnk file from Public Desktop (Win7) and write the results to a .log

Script Repository "publisher could not be verified" error

$
0
0

Hello,

I'm trying to add a script to the script repository, but when I test it to download it, I get the "publisher could not be verified" error. My script is not signed. I do not get this error when downloading other user's scripts, even though their scripts are not signed either. Is this an issue with signing my script? Why does my script receive this "publisher" error while other scripts do not? I don't want to scare users away with a big red error when they try to download my script! :(


Delete multiple AD users from Task Scheduler with PowerShell script

$
0
0

I'm hoping someone can assist with my issue. We have a termination script that will move users to a specific OU, disable the account, and set the expiration date to 60 days from now. That works great and we love it. What we need now is to execute a script via Task Scheduler on a daily basis to then delete those users that have Account Expires on that day's date. I have tried the following PowerShell script that launches from Task Scheduler:

From Task Scheduler

Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Argument: -ExecutionPolicy Bypass -NoLogo -NonInteractive -File C:\scripts\DeleteTermUser.ps1

DeleteTermUser.ps1 Script

Import-Module ActiveDirectory

$TermDate = Get-Date

$TermUsers = Get-ADUser -Filter {AccountExpirationDate -le $TermDate} -SearchBase "OU=Terminated,OU=Function,OU=Groups,DC=columnit,DC=com"

ForEach ($TermUser in $TermUsers) {
 Remove-ADUser $TermUser -Confirm:$False
}

--------------------------------------------

If I manually run this script I get the following:

Remove-ADUser : The server is unwilling to process the request
At C:\Scripts\DeleteTermUser.ps1:8 char:15
+     Remove-ADUser <<<<  $TermUser -Confirm:$False
    + CategoryInfo          : NotSpecified: (CN=Paul Smith,...ourdomain,DC=com:ADUser) [Remove-ADUser], ADException
    + FullyQualifiedErrorId : The server is unwilling to process the request,Microsoft.ActiveDirectory.Management.Comm
   ands.RemoveADUser

If I use the -WhatIf at the end then it tells me the following:

PS C:\Scripts> .\DeleteTermUser.ps1
What if: Performing operation "Remove" on Target "CN=Jon Smith,OU=Terminated,OU=Groups,DC=ourdomain,DC=com".

What if: Performing operation "Remove" on Target "CN=Guy Johnson,OU=Terminated,OU=Groups,DC=ourdomain,DC=com".

What if: Performing operation "Remove" on Target "CN=Bob Jones,OU=Terminated,OU=Groups,DC=ourdomain,DC=com".


I have numerous scripts running from Task Scheduler with no problem (all with Highest Privileges), but I can't wrap my head around this one.

Thanks in advance.

~Rick

Append anything to an email somehow to make it unique

$
0
0

We have a bizarre scenario I am having trouble wrapping my head around, I hope someone can help. I am new here (To my current employer and to script center) and trying to replace this terrible way of contacting our stores.

We have 900+ stores, each with 1 printer and not one user in the store can access a PC (Yes, not one user has access to anything) There are a few reasons why we do this, and we cannot work around this.

In order to communicate with one of the stores, a print job is sent to the printer. (They are all Brother MFCxxxx)

We use an archaic manor of sending these print jobs, by FAX!! (MetroFax)

Installed on each PC that needs to communicate with the stores (Again... yes this is the way we work) they send a Fax and it prints at the store.

SO...I have found an excellent utility; AutoEmailManager by Namtuk, and with a little customization we can now:

Send an email to the store (EX: 0001@ourstorename.com)
All 900+ stores are forwarded to one mailbox (all.stores@ourstorename.com)
The software looks in that mailbox every x minutes
Processes the user in the TO: field (0001) of each email and prints to the corresponding store printer

WOOP WOOP!! Problem solved!!!

NOPE!
When exchange receives an email (EX: I send an email to more than one store: 0001, 0002, 0003) it forwards the same email to multiple mailboxes. These mailboxes in turn send it to All.Stores, but it is not received as 3 emails, it is received as one with 3 recipients.

So now my question:
Can I make a transport rule somehow (It appears that with PowerShell scripting the rule, I can use variables) to perhaps add a prefix to the subject with the recipient (Or anything unique) so that each email is different and would appear as 3 emails in the all.stores mailbox?

A mouthful I am sorry, but I felt that a "Why do you want to do that?" question would appear so I tried to detail as much as possible. I look forward to questions and hopefully a solution!!

Derick


mailbox database size before & after backup

$
0
0

Hi there

i recently made a similar thread and someone told me that i should do it here so here is my issue :

i've been assigned to do a specific report related to exchange and its backup 
so what we want is a report that would give us the global size of all our mailbox databases before and after the backup ( even the size of the logs before and after)
(example : we have a mailbox database X: , we need to go inside the data folder, and retrieve the size of the .edb
then do the same thing with the logs, go inside the logs folder, and retrieve the logs size )

i was wondering if anyone ever managed to pull a script that does similar things, given the fact that i ve never worked with powershell and my knowledge is kinda limited in that area

Thanks

Get-Aduser(Inactive accounts)

$
0
0

I am able to use the script below just fine and save it to a .csv file. My issue is the distinguished name part, the script adds just part of the distinguished name and cuts off the rest with 3 dots (...). I need this to show the distinguished name in its entirety, any suggestions?

get-aduser -SearchBase "OU=User_Accounts,DC=DEVLAB,DC=LOCAL" -filter * -Properties lastlogondate, passwordlastset | Where-Object {($_.lastlogondate -le $90days -or $_.lastlogondate -notlike "*")-AND ($_.passwordlastset -le $90days) -AND ($_.Enabled -eq $True)} | Select-Object name,distinguishedname,lastlogondate,passwordlastset

Can I have both static text and the output of an array in the body of an email?

$
0
0

I have been scouring forums for something on this for a while now and have not found a whole lot. I'm trying to send a group of emails out to server owners in our company for a cleanup/consolidation project. I have a working script and of course now my boss wants it changed. I have the script set up to find all the servers a person owns and put it into a CSV file. Then it attaches it to an email with instructions on how to get everything updated. Now my boss does not want the list in an attachment but right in the body of the email. I'm pretty sure this is something Powershell can do, but I'm clueless on where to begin let alone how that would work.

Here is my current script minus the confidential stuff :) I just need to know where to start since it can't be in html format. I'd probably know if I knew powershell a little better, but well I've only been working with it for a few months now.

#Get SQL Database objects and places them into array $Sqldb
$Sqldb = New-Object System.Data.DataSet "myDataSet"
$sqlConn = New-Object System.Data.SqlClient.SqlConnection("Data Source=<SQL Server>;Initial Catalog=ServerBook;Integrated Security=True")
$adapter = New-Object System.Data.SqlClient.SqlDataAdapter("SELECT ServerName,Owner,SupportContact,SupportExternal,ServerDescription FROM v_ServerBook_BasicInfo", 
$sqlConn)
$adapter.Fill($Sqldb)	
#reorganizes $Sqldb by property owner
$Sqldb = $Sqldb.Tables[0] | Sort-Object -Property Owner
#stores list of unique owners and eliminates duplicates
$owners = ($Sqldb.owner | Get-Unique) 
#eliminates null values from the list of owners
$owners = $owners | where{$_ -ne "" -and $_ -ne $null -and $_ -ne [dbnull]::value} 
foreach($owner in $owners){
#Get the servers for the current owner
$servers = $Sqldb | where{$_.owner -eq $owner}
#CSV output filename ($owner.csv)
$newfile = "\\file\path\$owner.csv"
#Export the servers to the filename
$servers | select ServerName, Owner, SupportContact, SupportExternal, ServerDescription | Export-Csv -path $newfile -NoTypeInformation 
#copies the server owners name to $ownername variable
$ownerName = $owner 
#switches the format of the ownername variable to lastname,firstname
$Username = "$($Owner.Split(" ")[1]), $($Owner.Split(" ")[0])"
#gets email address for owner from AD
$EmailAddress = Get-ADuser -Filter "Name -eq '$Username'" -properties emailaddress -server ads.domain.com | select-object emailaddress 
#splits the $emailAddress vaiable to help eliminate extra text original text looks like @{emailaddress = John.Smith@Email.com}
$Emailaddress = $Emailaddress -split '[=}]' ,0
#removes extra text at the beginning of the variable leaving just John.Smith@email.com
$Emailaddress = $Emailaddress.TrimStart("@{emailaddress")
#stores the body of the email into a variable
$message = "Hello,
Blah Blah Blahbity Blah
Thank You,<Signature Block>"
#Sets the from email address
$emailFrom = "Jane.Doe@email.com" 
#Sets the email subject
$subject="Test Email" 
#sends the email with attachement for the current owner
Send-MailMessage -To "$EmailAddress" -Subject $subject -Body $message -SmtpServer "<smtp.domain.com>" -From $emailFrom  -Attachments $newfile -DeliveryNotificationOption OnSuccess
}


Powershell Results Output

$
0
0

I am using the following script to import a computer list and remove specific desktop icons:

Get-Content C:\Data\PS\Imports\24.csv |
      ForEach-Object{
           Get-Item "\\$($_.Name)\c$\users\Public\Desktop\Series *.lnk" -EA 0 |
                      Remove-Item}

I would like to log the success and failures. I have used the following 3 methods, none of which are working for me. Redirect and Transcript create blank files, while export creates nothing.

> "C:\Output.txt"

Start-Transcript -Path "C:\Output.txt" -Append

| Export-csv -Path "C:\Output.csv"

How to code it in powershell script?

$
0
0

In window 7, there are 2 power switch mode available for selections (balance or eco).

I would like to know on whether it is possible to code powershell script to switch those 2 modes within window 7 or not.

Does anyone have any suggestions?

Thanks in advance for any suggestions


Thanks in advance for any suggestions

Modifying attribute values in Powershell

$
0
0

Hi,

I am working on a script that is supposed to modify the value of an AD account attribute should it be blank.

The script is suppose to check if there is a value already present which would be either "staff" or "visitor". And if it isn't then it will execute the next block of the script where you will have to specify whether the user is a member of staff or a visitor. The code is below:

$username = Read-Host "Please enter username"
$employeeType = Get-ADUser $username -Properties * | fl employeeType
if (($employeeType -contains 'Staff') -or ($employeeType -contains 'Visitor'))
    {Write-Host "Employee attribute value exists"}
else {
    $visitorStaff = Read-Host "The EmployeeType attribute value does not exist. Please state wheather they are a Visitor or Staff"
    $replaceAttribute = New-Object hashtable
    $replaceAttribute.Add("employeeType", $visitorStaff)
    Set-ADUser $username -Replace $replaceAttribute
    }

The problem here is that when a valid employeeType value is set the script does not seem to recognise it and flows to the next block of the script to set the attribute value.

So when I do this from the Powershell Window:

echo $employeeType

I get:

employeeType : Staff

This in my mind seems correct. However, if do the following:

$employeeType -contains "Staff"

I get:

False

So I think I kind of understand why it never really sees a valid value and skips to the next else statement. But when I do this:

$employeeType.GetType()
I get a value where the BaseType is System.Array. Any ideas or suggestions as to how I can get this if statement to work will be much appreciated. I am using Windows 7 with Powershell v3.

Please let me know if you require further information.

Regards - MobileIAm

send s/mime encrypted mail with attachment

$
0
0

Hi Guys!

I've a tricky challenge.

I try to send powershell generated emails with an attachment and - on top - s/mime encrypted.

My current state of work:

send encrypted emails (without attachment) - success

send unencrypted emails (with attachment) - success

send encrypted emaisl (with attachment) - failed

Do anyone have a solution of this?

Thanks in advance!!!

regards - Thomminger

cls
$RecipientCN = $null
$RootDSE = $null
$Certificate = $null
$UserCertificate = $null
$ExcelFile = "C:\Temp\123.xlsx"

$RecipientCN='<cn>' 
$SearchForestForPerson = New-Object DirectoryServices.DirectorySearcher([ADSI]"LDAP://DC=domain,DC=com")
$SearchForestForPerson.SearchScope = "subtree" 
$SearchForestForPerson.PropertiesToLoad.Add("mail") | Out-Null 
$SearchForestForPerson.PropertiesToLoad.Add("usercertificate") | Out-Null 
$SearchForestForPerson.Filter = ("(&(objectClass=person)(CN=$RecipientCN))") 
$Recipient = $SearchForestForPerson.FindOne()

$ChosenCertificate = $null 
$Now = Get-Date 
If ($Recipient.Properties.usercertificate -ne $null) { 
    ForEach ($UserCertificate in $Recipient.Properties.usercertificate) { 
        $ValidForSecureEmail = $false 
        $Certificate = [System.Security.Cryptography.X509Certificates.X509Certificate2]$UserCertificate 
		$Extensions = $Certificate.Extensions 
        ForEach ($Extension in $Extensions) { 
            If ($Extension.EnhancedKeyUsages -ne $null) { 
                ForEach ($EnhancedKeyUsage in $Extension.EnhancedKeyUsages) { 
                    If ($EnhancedKeyUsage.FriendlyName -ine "Secure Email") { 
                        $ValidForSecureEmail = $true 
                        break 
                    } 
                } 
                If ($ValidForSecureEmail) { 
                    break 
                } 
            } 
        } 
        If ($ValidForSecureEmail) { 
            If ($Now -gt $Certificate.NotBefore.AddMinutes(-5) -and $Now -lt $Certificate.NotAfter.AddMinutes(5)) { 
                $ChosenCertificate = $Certificate 
            } 
        } 
        If ($ChosenCertificate -ne $null) { 
            break 
        } 
    } 
}


Add-Type -assemblyName "System.Security" 
$MailClient = New-Object System.Net.Mail.SmtpClient "<Smtp-Server>"
$Message = New-Object System.Net.Mail.MailMessage

$Message.To.Add($Recipient.properties.mail.item(0)) 
$Message.From = "<sender address>"
$Message.Subject = "Unencrypted subject of the message" 
$Body = "This is the mail body"
$MIMEMessage = New-Object system.Text.StringBuilder 
$MIMEMessage.AppendLine('Content-Type: text/plain; charset="UTF-8"') | Out-Null 
$MIMEMessage.AppendLine('Content-Transfer-Encoding: 7bit') | Out-Null 
$MIMEMessage.AppendLine() | Out-Null 
$MIMEMessage.AppendLine($Body) | Out-Null
$MIMEMessage.Append($ExcelFile) | Out-Null

[Byte[]] $BodyBytes = [System.Text.Encoding]::ASCII.GetBytes($MIMEMessage.ToString())

$ContentInfo = New-Object System.Security.Cryptography.Pkcs.ContentInfo (,$BodyBytes) 
$CMSRecipient = New-Object System.Security.Cryptography.Pkcs.CmsRecipient $ChosenCertificate 
$EnvelopedCMS = New-Object System.Security.Cryptography.Pkcs.EnvelopedCms $ContentInfo 
$EnvelopedCMS.Encrypt($CMSRecipient) 
[Byte[]] $EncryptedBytes = $EnvelopedCMS.Encode() 
$MemoryStream = New-Object System.IO.MemoryStream @(,$EncryptedBytes) 
$AlternateView = New-Object System.Net.Mail.AlternateView($MemoryStream, "application/pkcs7-mime; smime-type=enveloped-data;name=smime.p7m") 
$Message.AlternateViews.Add($AlternateView)

$MailClient.Send($Message)



Not able to run powershell script?

$
0
0

Under powershell, I get Unrestricted for this commend Get-ExecutionPolicy.

When I input .\ABC.psl, it returns not able to recognize '.\ABC.psl' as Cmdlet, number, command or executable file.

Location row: 1 , word: 14

.\ABC.psl <<<<<

CategoryInfo : ObjectNotFound: (.\ABC.psl:String) [], CommandNotFoundException

FullyQualifiedErrorId : CommandNotFoundException

Does anyone have any suggestions on what wrong it could be?
Thanks in advance for any suggestions

Scripts

# File is generated on 22-Jun-14 | Clean directory for the next update files
get-childitem D:\Temp\CSV -recurse |
 select -expand fullname |
 sort length -descending |
 remove-item


Thanks in advance for any suggestions


Get-wbsummary FOReach

$
0
0

Hi, please help! i'm sooo close!
i run a FOREACH on the function below against 4 servers.  if one of the servers is offline i only get 3 results back, how do i make it spit out a row indicating 'Command Failed' or 'Server unavailable' for the 4th server? 

what i get now is an html table with:
PSComputerName  LastBackupTime           LastBackupResultDetailedHR
server1                 6/18/2014 1:30:05 AM      0
server2                 6/18/2014 1:00:14 AM      0
server4                 6/17/2014 9:30:31 PM      0

And what i want is an html table with:

PSComputerName  LastBackupTime           LastBackupResultDetailedHR
server1                 6/18/2014 1:30:05 AM      0
server2                 6/18/2014 1:00:14 AM      0
server3                 NO RESPONSE or Command Failed
server4                 6/17/2014 9:30:31 PM      0

_____________________________________________________________________
function Get-WBStats

{
BEGIN {}
Process
{
Invoke-Command -ScriptBlock {
                                get-wbsummary
                            } -computername $Servername -credential $Cred | select PSComputerName,LastBackupTime,LastbackupResultDetailedHR | sort pscomputername                           
}
END {}
}

Thank you, any help is appreciated.

MN

How to add values to custom powreshell object

$
0
0

Hi Guy

 I'm new to powershell, i created a custom object via following codes

$a ='aaaa'
$b ='bbbb'
#Create a custom objec to save the output
$object = New-Object –TypeName PSObject
$object | Add-Member –MemberType NoteProperty –Name GroupName –Value $a
$object | Add-Member –MemberType NoteProperty –Name GroupName –Value $b

and write-oput $object should like this

GroupName                                                          GroupMember                                                      
---------                                                          -----------                                                      
aaaa                                                               bbbb                      

now what i want was add a new 'groupname' and 'groupmember' to the object , like

GroupName                                                          GroupMember                                                      
---------                                                          -----------                                                      
aaaa                                                               bbbb                    

cccc                                                               dddd

how can i achive this ?

                                       


FileSystemWatcher failing to read all new files in directory and hangs - Local Drive

$
0
0

Hey guys,

        I have FileSystemWatcher app watching for any new files created in a directory and writing a log file of everything new created. This part works great. However, I'm also trying to write this same data to an Access database and this is where everything get's screwy.

Randomly the FileSystemWatcher will stop processing files. It could be 2 files or 30 files and everything locks up and I need to restart the process. Any thoughts on this ? Here's my code im using. Like I said everything works great writing to a text file it's only when I incorporate the Access part stuff fails. I'm running Windows 7 64bit with Office 2010 64bit and Powershell 4.0.

I'm assuming it's something with my Access Insert statement but really unsure. This is my first attempt at dumping data to an Access database from Powershell. It also appears my Database isn't closing properly as my Access Lock file still exists when this whole process hangs.

If there's a better way to accomplish this im all ears. I do have the Log files with all the info I need a well. If I could import that to the Access database easier so the watcher doesn't hang I'm all ears on that one as well.

Thanks

Rich T.

 

#### DEFINE WATCH FOLDERS AND DEFAULT FILE EXTENSION TO WATCH FOR ####
        #$cofa_folder = '\\cpsfs001\Data_pvs\TestCofA'
        $cofa_folder = "c:\AdageCofA"
        #$bulk_folder = '\\cpsfs001\PVS\Subsidiary\Nolwood\McWood\POD'
        #$bulk_folder = 'c:\Bulk'
        $filter = "*.tif"
        $cofa = New-Object IO.FileSystemWatcher $cofa_folder, $filter -Property @{ IncludeSubdirectories = $false; EnableRaisingEvents= $true; NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' }
        #$bulk = New-Object IO.FileSystemWatcher $bulk_folder, $filter -Property @{ IncludeSubdirectories = $false; EnableRaisingEvents= $true; NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' }

#### CERTIFICATE OF ANALYSIS AND PACKAGE SHIPPER PROCESSING ####
            Register-ObjectEvent $cofa Changed -SourceIdentifier COFA/PACKAGE -Action {
         $name = $Event.SourceEventArgs.Name
         $changeType = $Event.SourceEventArgs.ChangeType
         $timeStamp = $Event.TimeGenerated
#### CERTIFICATE OF ANALYSIS PROCESS BEGINS ####
            $test=$name.StartsWith("I")
       if ($test -eq $true) {
            $pos = $name.IndexOf(".")
         $left=$name.substring(0,$pos)
         $pos = $left.IndexOf("L")
         $tempItem=$left.substring(0,$pos)
         $lot = $left.Substring($pos + 1)
         $item=$tempItem.Substring(1)

#### FOR TESTING ONLY. WILL OUTPUT DATA TO A POWERSHELL PROMPT
            Write-Host "in_item_key $item in_lot_key $lot imgfilename $name in_cofa_crtdt $timestamp"  -fore green
#### LOGS ALL TRANSACTIONS FOR CERTIFICATE OF ANALYSIS ####
            Out-File -FilePath c:\OutputLogs\CofA.txt -Append -InputObject "The file '$name' was $changeType at $timeStamp"

#### WRITES INFORMATION TO SQL DATABASE "AdageLIVE" ####
            $conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=PVSNTDB33; Initial Catalog=adagecopy_daily; Integrated Security=TRUE")
            $conn.Open()
            $insert_stmt = "INSERT INTO in_cofa_pvs (in_item_key, in_lot_key, imgfileName, in_cofa_crtdt) VALUES ($item,$lot,$name,$timestamp)"
            $cmd = $conn.CreateCommand()
            $cmd.CommandText = $insert_stmt
            $cmd.ExecuteNonQuery()
            $conn.Close()
            }
#### PACKAGE SHIPPER PROCESS BEGINS ####
          elseif ($test -eq $false) {
            $pos = $name.IndexOf(".")
         $left=$name.substring(0,$pos)
         $pos = $left.IndexOf("O")
         $tempItem=$left.substring(0,$pos)
         $order = $left.Substring($pos + 1)
         $shipid=$tempItem.Substring(1)

          
#### FOR TESTING ONLY. WILL OUTPUT DATA TO A POWERSHELL PROMPT ####
            Write-Host "so_hdr_key $order so_ship_key $shipid imgfilename $name in_cofa_crtdt $timestamp"  -fore green
#### LOGS ALL TRANSACTIONS FOR PACKAGE SHIPPERS ####
            Out-File -FilePath c:\OutputLogs\PackageShipper.txt -Append -InputObject "$order,$shipid,$name,$timeStamp"
#### WRITES INFORMATION TO MICROSOFT ACCESS DATABASE "G:\AdageCofA\CofA_140506.mdb" ####
            #Start-Sleep -s 10
            $conn=New-Object System.Data.OleDb.OleDbConnection("Provider=Microsoft.Ace.OLEDB.12.0; Data Source=c:\test.accdb")
            $conn.Open()
            $insert_stmt = "INSERT INTO dbo_so_shprimg_pvs (so_hdr_key, so_ship_key, imgfileName, so_shprimg_crtdt) VALUES ('$order','$shipid','$name','$timestamp')"
            $cmd = $conn.CreateCommand()
            $cmd.CommandText = $insert_stmt
            $cmd.ExecuteNonQuery()
            $conn.Close()
        }
}
#### BULK SHIPPER PROCESSING ####
            #Register-ObjectEvent $bulk Created -SourceIdentifier BULK -Action {
         #$name = $Event.SourceEventArgs.Name
         #$changeType = $Event.SourceEventArgs.ChangeType
         #$timeStamp = $Event.TimeGenerated
#### FOR TESTING ONLY. WILL OUTPUT DATA TO A POWERSHELL PROMPT ####
            #Write-Host "$name was $changeType at $timeStamp" -fore green
#### LOGS ALL TRANSACTIONS FOR BULK SHIPPERS ####
         #Out-File -FilePath c:\OutputLogs\BulkShipper.txt -Append -InputObject "$name,$timeStamp"
#}


# To stop the Nolwood Watcher Registered Event open Powershell and Type Unregister-Event *
# To start the Nolwood Watcher Registered Event open Powershell and navigate to c:\Users\02DocScan\Desktop and run the NolwoodFileWatcher.ps1


Rich Thompson


Error poweshell script (else command)

$
0
0

Hi 

I'm trying to make a script to run multiple commands depending on whether the equipment is online or not, but I get an error in the "else". 

Any idea?

$path = “E:\Inventory\”
$serverlist = get-content “$path\servers.txt”
foreach ($server in $serverlist){
 $result = Test-Connection $server -Count 1 -Quiet
 if ($result -eq “True”){
{.\psexec.exe \\$server -S gpupdate.exe /target:computer /force}
Start-Sleep -Seconds 5
}
 }
else
 {
 Add-Content “$path\noping.txt” -Value $server
 }

unlock-adaccount schedule task

$
0
0

how do i run a schedule task with the command

unlock-adaccount -identity "CN..........DC=COM"

i need it to run it every 2-3 hours

Select (copy, move or delete) larger of 2 files

$
0
0

hi all -

how do I move (or delete) the larger of 2 files within a directory?

I have a bunch of files with same name but different extension, e.g.,  file001.gif; file001.jpg; file002.gif; file002.jpg;

I want to end up with the smallest (fewest bytes) file, only, in the directory, but making sure I have exactly 1, only, of each filename. 

file001.gif;

file002.jpg;

file003.gif;

file004.gif; etc.

cheers, and tia

Is it possible to merge cell without specifying a range?

$
0
0

I am running a script with an XLSx function where I can output from multiple script and the output are stored in seprate worksheets. In 2 of my worksheets I have row name for each column, I have managed to remove (blank) the duplicate row value. Now I am looking to merge those cells whose colA rows are space. I understand that we need to specify the range for the cells to be merge. Is it possible to merge without specifying a range?

Viewing all 15028 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>