How to extract NIC information using Get-AzureRmVM cmdlet - azure

I want to generate CSV file containing the VM names and the network interfaces that are attached to them. When I run the cmdlet, I see the following output in table format
ResourceGroupName Name Location VmSize OsType NIC
When I try to select only the NIC object using the command Get-AzureRmVM | select-object NIC the output is blank.
Can anyone guide me on how to filter out the NIC names and the VM names ?

Because NIC not the project in Get-AzureRmVm, so we can't use Get-AzureRmVM | select-object NIC to get NIC name:
PS D:\testdata> get-azurermvm | gm
TypeName: Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineList
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToPSVirtualMachine Method Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine ToPSVirtualMachine()
ToString Method string ToString()
AvailabilitySetReference Property Microsoft.Azure.Management.Compute.Models.SubResource AvailabilitySetReference {...
DiagnosticsProfile Property Microsoft.Azure.Management.Compute.Models.DiagnosticsProfile DiagnosticsProfile ...
DisplayHint Property Microsoft.Azure.Commands.Compute.Models.DisplayHintType DisplayHint {get;set;}
Extensions Property System.Collections.Generic.IList[Microsoft.Azure.Management.Compute.Models.Virtu...
HardwareProfile Property Microsoft.Azure.Management.Compute.Models.HardwareProfile HardwareProfile {get;s...
Id Property string Id {get;set;}
Identity Property Microsoft.Azure.Management.Compute.Models.VirtualMachineIdentity Identity {get;s...
InstanceView Property Microsoft.Azure.Management.Compute.Models.VirtualMachineInstanceView InstanceVie...
LicenseType Property string LicenseType {get;set;}
Location Property string Location {get;set;}
Name Property string Name {get;set;}
NetworkProfile Property Microsoft.Azure.Management.Compute.Models.NetworkProfile NetworkProfile {get;set;}
OSProfile Property Microsoft.Azure.Management.Compute.Models.OSProfile OSProfile {get;set;}
Plan Property Microsoft.Azure.Management.Compute.Models.Plan Plan {get;set;}
ProvisioningState Property string ProvisioningState {get;set;}
RequestId Property string RequestId {get;set;}
ResourceGroupName Property string ResourceGroupName {get;}
StatusCode Property System.Net.HttpStatusCode StatusCode {get;set;}
StorageProfile Property Microsoft.Azure.Management.Compute.Models.StorageProfile StorageProfile {get;set;}
Tags Property System.Collections.Generic.IDictionary[string,string] Tags {get;set;}
Type Property string Type {get;set;}
VmId Property string VmId {get;set;}
Can anyone guide me on how to filter out the NIC names and the VM
names ?
As a workaround, we can use this script to get the NIC name:
$a = get-azurermvm -ResourceGroupName jasonvm -Name jasonvm
$b = $a.NetworkProfile.NetworkInterfaces.id -split "/"
$nic = $b[-1]
$nic
Then we can use $nic to get the information about NIC, like this:
Get-AzureRmNetworkInterface -Name $nic -ResourceGroupName jasonvm

Related

How to change the display name of description field of selector

I have a customization where I'm adding a Selector to a grid field that has a description field as follows:
[PXSelector(typeof(Search<EPEmployee.bAccountID,
Where<EPEmployee.status, Equal<SetupTypes.active>>>),
typeof(EPEmployee.acctCD),
typeof(EPEmployee.acctName),
SubstituteKey = typeof(EPEmployee.acctCD),
DescriptionField = typeof(EPEmployee.acctName))]
My problem is that the field has a description (in this case, 'Employee Name') field that is automatically added, but I can't find a way to change the display name of that field.
Since I have another field that uses the same employee lookup, they both have the same 'Employee Name' description field - so I have no way of knowing which description goes with which Selector field unless I choose a value and see the description show up in its associated 'Employee Name' field.
Is there a way to change the display name of that description field? I've tried CacheAttached and the RowSelected event with a PXUIFieldAttribute.SetDisplayName, but nothing seems to work.. seems that 'field_description' is an automatically added field that doesn't exist anywhere in the DAC to be able to change the display name.
Per Acumatica support, the only way that this can be done is as follows:
The only way that seems to work is to have two different DACs that are projections on the EPEmployee DAC and use each in the separate selector attribute.
For instance:
[PXProjection(typeof(EPEmployee))]
public class EPEmployeeTest : IBqlTable
{
#region BAccountID
...
#endregion
#region AcctCD
...
#endregion
public abstract class acctName : PX.Data.BQL.BqlString.Field<acctName> { }
[PXDBString(60, IsUnicode = true, BqlField=typeof(EPEmployee.acctName))]
[PXUIField(DisplayName = "Employee Name New Label", Enabled = false, Visibility = PXUIVisibility.SelectorVisible)]
public override string AcctName{get; set;}
}

Acumatica how to make a Custom Branch field not mandatory or be able to select branch from a lookup

I'm facing the following issue:
I have created a user field "UsrBranch".
Using the Branch lookup from the SO Financial Settings, I'm able to select and save into my new "UsrBranch" field, but it makes the field mandatory, even when I set the field as "Required = false".
Example 1:
[PXUIField(DisplayName = "Branch")]
[Branch(typeof(Coalesce<Search<Location.cBranchID,
Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,
And<Location.locationID, Equal<Current<SOOrder.customerLocationID>>>>>,
Search<Branch.branchID, Where<Branch.branchID,
Equal<Current<AccessInfo.branchID>>>>>), Required = false)]
public virtual Int32? UsrBranch { get; set; }
public abstract class usrBranch : PX.Data.BQL.BqlString.Field<usrBranch> { }
If I change the lookup to a PXSelector it displays the Branches, but I'm not able to select any.
Example 2:
[PXUIField(DisplayName = "Branch")]
[PXSelector(typeof(Branch.branchID),
SubstituteKey = typeof(Branch.branchCD))]
public virtual Int32? UsrBranch { get; set; }
public abstract class usrBranch : PX.Data.BQL.BqlString.Field<usrBranch> { }
Any Help will be gratefully appreciated.
The "Required" Property controls whether or not the star will show up on the field in the UI. The "PersistingCheck" property on the PXDefaultAttribute controls whether or not a value is mandatory.
The constructor of the BranchAttribute adds a PXDefaultAttribute to the field, and the default value for the "PersistingCheck" property is PXPersistingCheck.Null. This disallows the field from being null when saved. Since BranchAttribute derives from the AcctSubAttribute/PXAggregateAttribute you can set the "PersistingCheck" property on the BranchAttribute and it will set the "PersistingCheck" property on the added PXDefaultAttribute. To make it so the field can be null, set the "PersistingCheck" property to PXPersistingCheck.Nothing on the BranchAttribute:
[Branch(typeof(Coalesce<
Search<Location.cBranchID,
Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,
And<Location.locationID, Equal<Current<SOOrder.customerLocationID>>>>>,
Search<Branch.branchID,
Where<Branch.branchID, Equal<Current<AccessInfo.branchID>>>>>), PersistingCheck = PXPersistingCheck.Nothing)]
public virtual int? UsrBranch { get; set; }
Additionally, there is a PXUIFieldAttribute on the BranchAttribute so adding another one onto the field is redundant.

Adding Owner Name in the Purchase Order Lookup screen

I would like to add the Owner Name (on the PO Screen) in the Purchase Order>Order Nbr. field lookup screen. I tried to manually add the following in the Data Class for OrdNbr but it didn't bring the Employee name in the lookup screen. Can you please help or let me know if i am missing something.
Here is the full code i am trying(screenshot attached)
[PXCustomizeSelectorColumns(
typeof(PX.Objects.PO.POOrder.orderType),
typeof(PX.Objects.PO.POOrder.orderNbr),
typeof(PX.Objects.PO.POOrder.vendorRefNbr),
typeof(PX.Objects.PO.POOrder.orderDate),
typeof(PX.Objects.PO.POOrder.status),
typeof(PX.Objects.PO.POOrder.vendorID),
typeof(PX.Objects.PO.POOrder.vendorID_Vendor_acctName),
typeof(PX.Objects.PO.POOrder.vendorLocationID),
typeof(PX.Objects.PO.POOrder.curyID),
typeof(PX.Objects.PO.POOrder.curyOrderTotal),
typeof(PX.Objects.PO.POOrder.sOOrderType),
typeof(PX.Objects.PO.POOrder.sOOrderNbr),
typeof(PX.Objects.PO.POOrder.orderDesc),
typeof(PX.Objects.CR.CREmployee.acctCD),
typeof(PX.Objects.CR.CREmployee.bAccountID),
typeof(PX.Objects.CR.CREmployee.acctName))]
Many Thanksenter image description here
Since POOrder.employeeID has a PXSelector attribute on its definition:
And this Selector has a DescriptionField assigned:
On this case you can add Owner name by adding this line of code to your CacheExtension file(This will obtain that DescriptionField for the EmployeeID field):
public abstract class employeeID_CREmployee_acctName : PX.Data.IBqlField { }
See Snippet below:
namespace PX.Objects.PO
{
[PXNonInstantiatedExtension]
public class PO_POOrder_ExistingColumn : PXCacheExtension<PX.Objects.PO.POOrder>
{
#region OwnerName
public abstract class employeeID_CREmployee_acctName : PX.Data.IBqlField
{ }
#endregion
#region OrderNbr
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.PO.POOrder.orderType),
typeof(PX.Objects.PO.POOrder.orderNbr),
typeof(PX.Objects.PO.POOrder.vendorRefNbr),
typeof(PX.Objects.PO.POOrder.orderDate),
typeof(PX.Objects.PO.POOrder.status),
typeof(PX.Objects.PO.POOrder.employeeID),
typeof(PX.Objects.PO.PO_POOrder_ExistingColumn.employeeID_CREmployee_acctName),
typeof(PX.Objects.PO.POOrder.vendorID),
typeof(PX.Objects.PO.POOrder.vendorID_Vendor_acctName),
typeof(PX.Objects.PO.POOrder.vendorLocationID),
typeof(PX.Objects.PO.POOrder.curyID),
typeof(PX.Objects.PO.POOrder.curyOrderTotal),
typeof(PX.Objects.PO.POOrder.sOOrderType),
typeof(PX.Objects.PO.POOrder.sOOrderNbr))]
public string OrderNbr { get; set; }
#endregion
}
}
Please notice that in case the POOrder.EmployeeID field would not have the "DescriptionField" set on the PXSelector Definition, you would have to modify the PXSelector of the OrderNbr to add a LeftJoin on the Desired Table(CREmployee on this case) so you could use the desired fields and add them to the PXCustomizeSelectorColumns attribute.

How to default an employeeid field to the current logged in user

I have a custom inquiry screen which uses an employeeid as the header filter field. What I'd like to do is default that employeeid field to the current logged in user, if possible. I've tried the following, but both give me a cast error (version 5.3.2562):
1.) [PXDBDefault(typeof(Search<EPEmployee.bAccountID,
Where<EPEmployee.bAccountID, Equal<Current<AccessInfo.userID>>>>))]
2.) [PXDBDefault(typeof(AccessInfo.userID))]
Here's the entire DAC code for the filter field:
#region EmployeeID
public abstract class employeeID : IBqlField
{
}
[PXInt]
[PXDBDefault(typeof(AccessInfo.userID))]
[PXUIField(DisplayName = "Employee ID")]
[PXSelector(typeof(Search<EPEmployee.bAccountID,
Where<EPEmployee.status, Equal<SetupTypes.active>>>),
typeof(EPEmployee.acctCD),
typeof(EPEmployee.acctName),
SubstituteKey = typeof(EPEmployee.acctCD),
DescriptionField = typeof(EPEmployee.acctName))]
public virtual int? EmployeeID { get; set; }
#endregion
What's the correct way to obtain this?
Update 6/30/2017:
After implementing the solution (using PXDefault instead of PXDBDefault) as follows:
[PXDefault(typeof(Search<EPEmployee.bAccountID,
Where<EPEmployee.bAccountID, Equal<Current<AccessInfo.userID>>>>))]
I get the following error:
We have a non filter field in a transaction able that defaults to the current employee.
This should work:
[PXDefault(typeof(Search<EPEmployee.bAccountID,
Where<EPEmployee.bAccountID, Equal<Current<AccessInfo.userID>>>>))]
Note that you do not want to use PXDBDefault for default values unless they are values coming from a parent DAC when linked with PXParent. Use PXDefault for defaults.
If this does not work in your filter, try PXUnboundDefault in place of PXDefault.
Edit 6/30/2017: new error might be on your selector. There is an employee selector already available. Remove your PXSelector and use [PXEPEmployeeSelector] on your field and see if this solves your error between uniqueidentifier and int
AccessInfo.userID seems to be a GUID. In order to avoid the casting error you need to relate AccessInfo.userID to EPEmployee.userID while searching for EPEmployee.bAccountID. Final code should look like this:
#region EmployeeID
public abstract class usrEmployeeID : IBqlField
{
}
[PXEPEmployeeSelector]
[PXUnboundDefault(typeof(Search<EPEmployee.bAccountID,
Where<EPEmployee.userID, Equal<Current<AccessInfo.userID>>>>))]
[PXUIField(DisplayName = "Employee ID")]
public virtual int? UsrEmployeeID { get; set; }
#endregion

IIS Enable the HTTP Keep-Alive in Powershell

The page http://technet.microsoft.com/en-us/library/cc772183(v=ws.10).aspx explains how to Enable the HTTP Keep-Alive Response Header (IIS 7)
I want to do this in Powershell by WMI
It says:
Use the following WMI classes, methods, or properties to perform this
procedure:
HTTPProtocolSection.AllowKeepAlive property
I've tried:
PS > Get-WmiObject -Class HTTPProtocolSection
Get-WmiObject : Invalid class
At line:1 char:14
+ Get-WmiObject <<<< -Class HTTPProtocolSection
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
What's the right way of using this HTTPProtocolSection class and enabling AllowKeepAlive property?
You can also set it with the Set-WebConfiguration cmdlet:
Set-WebConfiguration -Filter system.webServer/httpProtocol -PSPath MACHINE/WEBROOT/APPHOST -Value #{allowKeepAlive=$true}
To discover class in a particular namespace try this
PS c:\>Get-WmiObject -List * "root\webadministration"
and to find a match do this
PS c:\>Get-WmiObject -List * "root\webadministration" | Where-Object {$_.name -match "Http"}
PS C:\>Get-WmiObject -Namespace "root\webadministration" -class HttpProtocolSection | Get-Member
TypeName: System.Management.ManagementObject#root\webadministration\HttpProtocolSection
Name MemberType Definition
---- ---------- ----------
PSComputerName AliasProperty PSComputerName = __SERVER
Add Method System.Management.ManagementBaseObject Add(System.String CollectionName, System.Ma...
Clear Method System.Management.ManagementBaseObject Clear(System.String CollectionName)
Get Method System.Management.ManagementBaseObject Get(System.String CollectionName, System.St...
Remove Method System.Management.ManagementBaseObject Remove(System.String CollectionName, System...
RevertToParent Method System.Management.ManagementBaseObject RevertToParent(System.String PropertyName)
AllowKeepAlive Property bool AllowKeepAlive {get;set;}
CustomHeaders Property System.Management.ManagementObject#CustomHeaderSettings CustomHeaders {get;set;}
Location Property string Location {get;set;}
Path Property string Path {get;set;}
RedirectHeaders Property System.Management.ManagementObject#RedirectHeaderSettings RedirectHeaders {get;set;}
SectionInformation Property System.Management.ManagementObject#SectionInformation SectionInformation {get;set;}
__CLASS Property string __CLASS {get;set;}
__DERIVATION Property string[] __DERIVATION {get;set;}
__DYNASTY Property string __DYNASTY {get;set;}
__GENUS Property int __GENUS {get;set;}
__NAMESPACE Property string __NAMESPACE {get;set;}
__PATH Property string __PATH {get;set;}
__PROPERTY_COUNT Property int __PROPERTY_COUNT {get;set;}
__RELPATH Property string __RELPATH {get;set;}
__SERVER Property string __SERVER {get;set;}
__SUPERCLASS Property string __SUPERCLASS {get;set;}
ConvertFromDateTime ScriptMethod System.Object ConvertFromDateTime();
ConvertToDateTime ScriptMethod System.Object ConvertToDateTime();
You can then do something like this to get the value of AllowKeepAlive
PS C:\> (get-wmiobject -namespace "root\webadministration" -class HttpProtocolSection).AllowKeepAlive
True
PS C:\>$a = Get-WmiObject -Namespace "root\webadministration" -class HttpProtocolSection
PS C:\>$a.AllowKeepAlive = $false
PS C:\>$a.Put()

Resources