Fail to change "AddressState" using powershell cmdlet "Set-NetIPAddress"
PS C:\Users\webadm> Get-NetAdapter | Get-NetIPAddress IPAddress : 10.145.0.118 InterfaceIndex : 12 InterfaceAlias : Ethernet AddressFamily : IPv4 Type : Unicast PrefixLength : 24 PrefixOrigin : Manual SuffixOrigin : Manual AddressState : Deprecated ValidLifetime
: Infinite ([TimeSpan]::MaxValue) PreferredLifetime : 00:00:00 SkipAsSource : False PolicyStore : ActiveStore PS
C:\Users\webadm> Get-NetAdapter | set-NetIPAddress -IPAddress 10.145.0.118 -AddressFamily IPv4 -AddressState Preferred set-NetIPAddress : No matching MSFT_NetIPAddress objects found by CIM query for instances of the ROOT/StandardCimv2/MSFT_NetIPAddress
class on the CIM server: SELECT * FROM MSFT_NetIPAddress WHERE ((IPAddress LIKE '10.145.0.118')) AND ((InterfaceIndex = 12)) AND ((InterfaceAlias LIKE 'Ethernet')) AND ((AddressFamily = 2)) AND ((AddressState = 4)). Verify query parameters and retry. At line:1
char:18 + Get-NetAdapter | set-NetIPAddress -IPAddress 10.145.0.118 -AddressFamily IPv4 -A ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (MSFT_NetIPAddress:String) [Set-NetIPAddress],
CimJobException + FullyQualifiedErrorId : CmdletizationQuery_NotFound,Set-NetIPAddress
Can anyone tell what's going wrong? thanks.
Hello !
To add an IP address, you have to use New-NetIPAddress cmdlet.
Example:
New-NetIPAddress -InterfaceIndex 12 -IPv4Address 10.145.0.118 -PrefixLength 24
If you have to remove the
10.145.0.118 address, you can use Remove-NetIPAddress.
Hope this helps.
Note: This posting is provided 'AS IS' with no warranties or guarantees, and confers no rights. Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable. This helps the community, keeps the forums tidy, and
recognises useful contributions.
Similar Messages
-
Using Powershell to set Multiple timed.servers with variables
Having an issue using PowerShell to set 3 timed.servers which are defined in a variable. Running the commands: $TimeServers = "IPaddress1,IPaddress2,IPaddress3"Set-NaOption -OptionName timed.servers -OptionValue $TimeServers Thanks in advance!
Hi, The Set-NaOption CmdLet -optionvalue parameter expects a string and it shouldn't matter if that's a comma delimited string containing multiple IP Addresses. I noticed that whilst the cmdlet thows an error it does actually set the option value for all servers so this seems like it could be a bug (IMO). It might be possible to invoke the API using "Invoke-NaSystemApi" but I checked the ZAPI and noticed this also fails using ZExplore from the SDK: ZAPI Request: <?xml version="1.0" encoding="UTF-8"?>
<netapp xmlns="http://www.netapp.com/filer/admin" version="1.21">
<options-set>
<name>timed.servers</name>
<value>192.168.100.10,192.168.100.11,192.168.100.12</value>
</options-set>
</netapp> ZAPI Results: <?xml version='1.0' encoding='UTF-8' ?>
<netapp version='1.1' xmlns='http://www.netapp.com/filer/admin'>
<!-- Output of options-set [Execution Time: 8610 ms] -->
<results reason='Unable to set option: timed.servers' errno='13001' status='failed'>
<cluster-constraint>same_preferred</cluster-constraint>
<cluster_constraint>same_preferred</cluster_constraint>
<message>1 entry was deleted.
</message>
</results>
</netapp> So i think the options are either using the "Set-NaOption" cmdlet with the -SilentlyContinue parameter or the "Invoke-NaSsh" cmdlet with -ErrorAction stop.As a work around i'd recommend something like: [String]$servers = "192.168.100.10,192.168.100.11,192.168.100.12"
[String]$command = "options timed.servers $servers"
Try{
Invoke-NaSsh -Command $command -ErrorAction Stop
Write-Host "Executed Command: $command"
}Catch{
Write-Warning -Message $("Failed Executing Command: $command. Error " + $_.Exception.Message)
} Hope that helps /matt -
How to use Powershell to set delegate for user mailbox in Exchange 2010 and Office 365
Hello,
Can you please tell me if I can set delegate for user mailbox in Exchange 2010 or Office 365 using Powershell?
If I can, then how can I do that? (which Powershell commands for setting the delegate?)
Many thanks, and have a good day!Hi,
If you wanted to add a delegate to possiblly a large number of users or you do this during mailbox provisioning. So the following script will use
impersonation to access another users mailbox and add a delegate.
$mbtoDelegate = "[email protected]"
$delegatetoAdd = "[email protected]"
$dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.0\Microsoft.Exchange.WebServices.dll"
[void][Reflection.Assembly]::LoadFile($dllpath)
$service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1)
$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
$aceuser = [ADSI]$sidbind
$service.AutodiscoverUrl($aceuser.mail.ToString())
$service.ImpersonatedUserId = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress,
$mbtoDelegate);
$mbMailbox = new-object Microsoft.Exchange.WebServices.Data.Mailbox($mbtoDelegate)
$dgUser = new-object Microsoft.Exchange.WebServices.Data.DelegateUser($delegatetoAdd)
$dgUser.ViewPrivateItems = $false
$dgUser.ReceiveCopiesOfMeetingMessages = $false
$dgUser.Permissions.CalendarFolderPermissionLevel = [Microsoft.Exchange.WebServices.Data.DelegateFolderPermissionLevel]::Editor
$dgUser.Permissions.InboxFolderPermissionLevel = [Microsoft.Exchange.WebServices.Data.DelegateFolderPermissionLevel]::Reviewer
$dgArray = new-object Microsoft.Exchange.WebServices.Data.DelegateUser[] 1
$dgArray[0] = $dgUser
$service.AddDelegates($mbMailbox, [Microsoft.Exchange.WebServices.Data.MeetingRequestsDeliveryScope]::DelegatesAndMe, $dgArray);
Hope this helps. -
Fail to create VM using PowerShell commands
I tried to create a new VM with Public IP. The only way I found was using PowerShell.
This was the commands I used.
$vm = New-AzureVMConfig -Name "mu0035" -InstanceSize Small -ImageName "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_1-LTS-amd64-server-20140924-en-us-30GB"| Add-AzureProvisioningConfig -Linux -LinuxUser $username -Password $password|Set-AzurePublicIP -PublicIPName "mu0035PIP"
It returns `BadRequest: The location or affinity group East Asia of the storage account where the source image b39f27a8b8c64d52b05eac6a62ebad85 resides is not in the same location as the specified cloud service ,"Southeast Asia"`.
It seems the image locate in East Asia, and I want to create VM in 'Southeast Asia'.
Interest thing is, I have already set the subscription's currentstorageaccount to a `Southeast Asia` storage account.
Get-AzureSubscription -Current
SubscriptionId : $subscription_id
SubscriptionName : BizSpark
Environment : AzureCloud
SupportedModes : AzureServiceManagement,AzureResourceManager
DefaultAccount : $account_name
Accounts : {$account_name}
IsDefault : True
IsCurrent : True
CurrentStorageAccountName : sourtheast
Get-AzureStorageAccount -StorageAccountName sourtheast
StorageAccountDescription :
AffinityGroup :
Location : Southeast Asia
GeoReplicationEnabled : True
GeoPrimaryLocation : Southeast Asia
GeoSecondaryLocation : East Asia
Label : sourtheast
StorageAccountStatus : Created
StatusOfPrimary : Available
StatusOfSecondary : Available
Endpoints : {https://sourtheast.blob.core.windows.net/, https://sourtheast.queue.core.windows.net/, https://sourtheast.table.core.windows.net/}
AccountType : Standard_GRS
StorageAccountName : sourtheast
OperationDescription : Get-AzureStorageAccount
OperationId : f1326e6e-951d-1c9c-bb4d-4a65900025bb
OperationStatus : Succeeded
I can't figure out what happened. Why the powershell command not fetching the image from a wrong location?
Please, Help!Hi, it looks as though the "StorageAccountName" is set to "sourtheast", possibly just a typo when the accountname was created?
-
Office 365 - Changing Domain using Powershell
Hi,
I have about a hundred users on a domain ([email protected]) and I need to change to another domain ([email protected]) using Powershell.
May I know what commands are needed to accomplish this? I need to change the userPrincipalName, SIP and Primary SMTP to the new domain.
I have all the users in a CSV file.
Thanks!!Hi Kindovic,
To bulk add user information from CSV file, please check the script below:
Bulk import the user information from CSV file
How to create users in bulk using csv file import
For the issue of office 365, I also recommend you to post this in Office 365 forum for more effective support:
Manage Office 365
Best Regards,
Anna -
Using PowerShell to set Custom Access Rights on a Calendar Does not set Free/Busy Permissions
We recently discovered an issue where, if you use Exchange Management Shell to configure custom access rights, the Free/Busy permissions do not get set at all (they remain as "None"):
$temp = [Microsoft.Exchange.Management.StoreTasks.MailboxFolderAccessRight[]]("ReadItems","EditOwnedItems","DeleteOwnedItems","EditAllItems","DeleteAllItems","FolderVisible")
Add-MailboxFolderPermission -Identity "conf-company-test:\calendar" -User "Company Calendar Management" -AccessRights $temp
Add-MailboxFolderPermission -Identity "conf-company-test:\calendar" -User "mpinkston" -AccessRights Editor
If you use a pre-defined "role" such as Editor given to mpinkston6 in the above example it sets the Free/Busy permission to Full Details. It would appear that using Add-MailboxFolderPermission or Set-MailboxFolderPermission is generic for folder
objects, and doesn't explicitly set the Free/Busy permissions. In the case of the pre-defined roles either the command is doing something special/different, or the permission checks later accept pre-defined roles for determining Free/Busy permissions. No idea
which is going on. If Free/Busy permissions can be fixed through PowerShell by some other mechanism/command, that would be great. If not, how do we go about requesting a fix/feature change in Exchange?
http://technet.microsoft.com/en-us/library/dd298062%28v=exchg.150%29.aspx
(Please expand Parameters and read AccessRights to get a better understanding for what I'm describing.)Did you try adding AvailabilityOnly or LimitedDetails in your $temp variable for Calendar folder? These would set it to "Free/Busy time, subject, location" or "Free/Busy time" respectively....
Add-MailboxFolderPermission - http://technet.microsoft.com/en-us/library/dd298062(v=exchg.150).aspx
The following roles apply specifically to calendar folders:
AvailabilityOnly View only availability data
LimitedDetails View availability data with subject and location
Amit Tank | Exchange - MVP | Blog:
exchangeshare.wordpress.com -
Create Device Collection WITH Refresh Schedule using Powershel CMDLets
Hello everyone
I'm attempting to create a PowerShell script to create a device collection and I'm running into a very frustrating issue. I want to be able to set the collections refresh time but can't seem to get it to work. This code here works to create the
collection and tell it to do incremental updates but I cannot figure out how to set refresh time. Everything I've attempted has failed and google seems to be no help right now.
$CollectionName = "Test"
$CollectionQueryValue = 'select * from SMS_R_System inner join SMS_G_System_SYSTEM on SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.NetBIOSName in ("Hostname")' $CollectionQueryName = "Direct by Hostname"
New-CMDeviceCollection -Name $CollectionName -LimitingCollectionName "All Systems" -RefreshType ConstantUpdate
Thanks for your help!I haven't tried it, but the following should work:
$Sched = New-CMSchedule -Start "01/02/2014 1:00 AM"
-DayOfWeek Sunday -RecurCount 1
New-CMDeviceCollection -Name "C1"
-LimitingCollectionName "All Systems" -RefreshSchedule $Sched -RefreshType Both
Torsten Meringer | http://www.mssccmfaq.de -
PowerShell cmdlet Set-Mailbox parameters not working
Great suggestion, will do. Thanks Matthew.
Essentially I'm just trying to set Shared Mailbox default behaviour for when a user sends an email from that mailbox the sent email is placedin the Shared Mailbox sent folder instead of the users sent folder which is what it does now. This is supposed to be possible with Powershell according to MS. We're using Office 365 Enterprise for this. The error is the following:PS C:\ Get-Mailbox TestSharedMailbox | select *message*MessageCopyForSentAsEnabled : FalseMessageCopyForSendOnBehalfEnabled : FalseMessageTrackingReadStatusEnabled : TrueDowngradeHighPriorityMessagesEnabled : FalsePS C:\ Set-Mailbox TestSharedMailbox -MessageCopyForSentAsEnabled $TrueA parameter cannot be found that matches parameter name 'MessageCopyForSentAsEnabled'. + CategoryInfo : InvalidArgument: (:) [Set-Mailbox], ParameterBindingException + FullyQualifiedErrorId :...
This topic first appeared in the Spiceworks Community -
PowerShell Cmdlet to rename a RDS Collection
Hi,
I am interacting with RDS Connection Broker via PowerShell Cmdlets. I want to rename a Collection using PowerShell Cmdlets. I have tried several Cmdlets specifically Set-RDVirtualDesktopCollectionConfiguration but it doesn't allow to change the name
of the collection. I know it is possible to rename using the RDS CB user interface but the requirements are to use only Power Shell cmdlets. Is it possible using cmdlets? or is there some other way to rename the collection without using RDS Connection Broker
user interface?
ThanksHi,
As this case has been quiet for a while.I need to close the case and will mark it as Answer. If this case is still unresolved,I suggest you ask in a new thread.
Thanks for your Support & understanding!
Regards.
Dharmesh Solanki
TechNet Community Support -
Configure service application associations using PowerShell
Hi all,
I have configured my service applications with PowerShell scripts and created a new web applications (also with PowerShell scripts).
However, I don't seem to find the necessary information on how to configure the service application to be used by this new web application using PowerShell cmdlets.
Any idea on how to do this?
Thanks in advance,
FlorinWhat you're describing is called a Proxy Group. You add Service Application Proxies to the Service Application Proxy Group, and that Proxy Group is assigned to the Web Application.
Step 1:
Use
New-SPServiceApplicationProxyGroup
Step 2:
Add Service Application Proxies by adding Members via
Add-SPServiceApplicationProxyGroupMember
Step 3:
Assign the Proxy Group to the Web Application via
Set-SPWebApplication -ServiceApplicationProxyGroup
Let us know if you need further help.
Trevor Seward
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs. -
How to send digitally sign S/MIME messages with Powershell cmdlet Send-MailMessage?
Hello,
using AD Windows PKI I assigned a certificate EKU (1.3.6.1.5.5.7.3.4) to sign emails and get this with
autoenrollment also to my CERT Store PS
CERT:\CurrentUser\UserDS\ or the certificate could found via MMC / certificates in the store structur under "Active Directory User Object".
Signed messages (red icon) to send as S/MIME message using Outlook 2010 is not a problem.
Using PowerShell cmdlet Send-MailMessage to be sent company notification for a new passwordpolicy some days before pwd expired?! I use the cmdlet already successfully to filling HTML bodies with variables and send to individuals accounts.
Reduced simplified PS code:
$SMTPBodyHtmlTemplate = Get-Content "C:\PS\Template\HTMLBody.html" | Out-String
Function SendEmailNotification # /* SEND E-MAIL Notification to User */#
[string] $SMTPServer = "mail.domain.local"
$CurrentUser = "$env:username"
[string]$SMTPFrom = (Get-ADUser $CurrentUser -properties mail).mail
[string[]] $SMTPTo = $($Obj.EmailAddress)
[string]$SMTPSubject = "Notification!"
[String]$SMTPBodyHtml = $SMTPBodyHtmlTemplate.Replace("UserDisplayname","$($UserDisplayname)")
Send-MailMessage -From $SMTPFrom -To $SMTPTo -Subject $SMTPSubject -BodyAsHtml $SMTPBodyHtml -dno OnFailure -SmtpServer $SMTPServer -encoding ([System.Text.Encoding]::UTF8) -ErrorAction Continue
How can I use the PSDrive own CERT and using PowerShell cmdlet Send-MailMessage
to send a signed message, without development experience?
Thanks in advance for cooperation.
Manfred SchülerHi,
could create with an other colleague a DLL file (with this informations) for successfully sending sign messages from PS-Script.
Function SendEmailNotification # /* SEND SIGN E-MAIL */#
$SMTPBodyHtmlTemplate = Get-Content "C:\PS\Template\HTML.html" | Out-String
[System.Reflection.Assembly]::LoadFile("C:\PS\Assembly\Cpi.Net.SecureMail.dll") | Out-Null
[string]$strSmtpServer = "smtp.domain.local"
[string]$strSmtpPort = "25"
[string]$strFrom = (Get-ADUser $CurrentUser -properties mail).mail
[string]$strFromAlias = (Get-ADUser $CurrentUser -properties DisplayName).DisplayName
[string]$strTo = $UserEmailAddress
[string]$strToAlias = $UserEmailDisplayName
[String]$strSubject = "Subject as you like"
[string]$strBody = $SMTPBodyHtmlTemplate.Replace("UserDisplayname","$($UserDisplayname)")
$objMail = New-Object Cpi.Net.SecureMail.SecureMailMessage
$objFrom = New-Object Cpi.Net.SecureMail.SecureMailAddress($strFrom,$strFromAlias,$objCert,$objCert)
$objTo = New-Object Cpi.Net.SecureMail.SecureMailAddress($strTo,$strToAlias)
$objMail.From = $objFrom
$objMail.to.Add($objTo)
$objMail.Subject = $strSubject
$objMail.Body = $strBody
$objMail.IsBodyHtml = $TRUE
$objMail.IsSigned = $TRUE
$objMail.IsEncrypted = $FALSE
$objSMTPClient = New-Object System.Net.Mail.SmtpClient($strSmtpServer,$strSmtpPort)
$objSMTPClient.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$objSMTPClient.send($objMail)
Maybe Microsoft can implement this in future versions of the cmdlets Send-MailMessage ;-)
Manfred Schüler -
I am trying to use powershell cmdlets to pull up the health state of certain groups like "agent" and "Health Service" from a specific custom created state view in Operations manager. Is this possible? If so what is the syntax?
Thanks!Hi
You can pull information from sate view but you can query group using below code
import-module operationsmanager
New-SCOMManagementGroupConnection
$gp=Get-SCOMGroup -DisplayName "operations Manager Agents"
Get-SCOMMonitoringObject -Group $gp |select HealthState,Displayname
Regards
sridhar v -
Set Primary DNS Suffix Using Powershell
For a Windows Server 2012 installation, what Powershell cmdlet can be used to change the Primary DNS Suffix ? I've tried using 'Set-DnsClientGlobalSetting -SuffixSearchList contoso.com' but this only alters the DNS Suffix Search List, not the primary DNS
suffix.You might want to take you question to one of two forums that specialist in scripting issues.
For PowerShell specific questions -
http://social.technet.microsoft.com/Forums/en-US/home?forum=winserverpowershell
For general scripting questions -
http://social.technet.microsoft.com/Forums/en-US/home?forum=ITCG
They have a lot of really sharp scripting people in those forums.
.:|:.:|:. tim -
How to get Document Set property values in a SharePoint library in to a CSV file using Powershell
Hi,
How to get Document Set property values in a SharePoint library into a CSV file using Powershell?
Any help would be greatly appreciated.
Thank you.
AA.Hi,
According to your description, my understanding is that you want to you want to get document set property value in a SharePoint library and then export into a CSV file using PowerShell.
I suggest you can get the document sets properties like the PowerShell Command below:
[system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint")
$siteurl="http://sp2013sps/sites/test"
$listname="Documents"
$mysite=new-object microsoft.sharepoint.spsite($siteurl)
$myweb=$mysite.openweb()
$list=$myweb.lists[$listname]
foreach($item in $list.items)
if($item.contenttype.name -eq "Document Set")
if($item.folder.itemcount -eq 0)
write-host $item.title
Then you can use Export-Csv PowerShell Command to export to a CSV file.
More information:
Powershell for document sets
How to export data to CSV in PowerShell?
Using the Export-Csv Cmdlet
Thanks
Best Regards
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
Change content of default.aspx for subsites using Powershell
Hi.
I need to update the content of the default.aspx of 60+ subsites in a site Collection. I am able to loop all subsites and get the corresponding default.aspx files using a PowerShell snippet like:
$site = Get-SPSite -WebApplication https://mysite.domain.no/ -Limit All
$wc = $site.allwebs | where {$_.url.StartsWith(https://mysite.domain.no/sites/blahblah/blahblahblah) }
foreach ($web in $wc){
$file = $web.GetFile("default.aspx")
The problem is I don't know whether to use the Set-Content command-let or an XMLDocument approach.
I have the file With the correct content on the local machine. I tried With $file.Parentfolder in order to use
$f = $web.GetFolder($file.ParentFolder)
$fc = $f.files
Get-ChildItem "C:\temp\default.aspx" | foreach {
$spFileCollection.add($($_.Name),$_.OpenRead(), $true)
to replace the file but this gives an error on empty folder. Can I use this approach or is there a way to change the actual content of the file?Hi Jorgen,
According to your description, my understanding is that you want to update the page content using PowerShell.
I suggest you read the content data like below:
$data = $file.OpenBinary()
$encode = New-Object System.Text.ASCIIEncoding
$test = $encode.GetString($data)
Then you can change the string you want, and then you can save it using SaveBinary() method.
Here are some detailed articles for your reference:
Reading the contents of a SharePoint library file using PowerShell
Using powershell to read/modify/rewrite sharepoint xml document
Best Regards
Zhengyu Guo
TechNet Community Support
Maybe you are looking for
-
I used to be able to print from the browser, specifically Amazon...hit print and I would get the print/preview from windows. In IE it worked perfectly, but IE start messing up and grinding to halt, taking MINUTES to load a page, like dial-up! Firefox
-
Document pricing procedure in Billing
Dear All, Can anybody tell me, what is the use of having a document price procedure in billing doc type ? Rgds, Indrajit
-
Help Needed Sony Monitor Cable Hookup
I just received my Sony PVM 14-L2 monitor today for color correcting and need help with what cables I should use. I have a Canon Elura camcorder that I will be using as a deck. Please guide me on which ones I should use as I don't want to buy/use the
-
Since the Maverick update, iPhoto 11 exporting of a slideshow no longer works. It did prior to the update. The more flexible drop down menu when selecting Export has been replaced by 3 choices; 480p, 720, and 1080p. Any suggestions?
-
IPhone 3G shuts itself down, battery @ 0
This used to happen sometimes, but now my iPhone shuts itself down with full battery status, and when I turn it on again, the battery is at zero. Any good idea what I might do (except buying a 4G 3 months before the 5G comes out)? Thank you! hp